PostgreSQL useful commands

Here is a collection of commands that I use frequently to connect and operate on a PostgreSQL database:

To connect to a remote postgresql (pgsql) database:

psql -h <hostname> -U <username> <dbname>

Hit Enter and enter password to connect to the DB.

hostname - host where the database resides

username - user for the schema

dbname - db which is accessible by the user

List available postgresql databases:

\l (small L)

List available tables under a postgresql database:

After you connect to a database as described above, run this


Describe columns of a postgresql table:

\d <table name>

Display data from multiple tables:


User login

Who's new

  • amitbhagwat
  • TenLekerand
  • ClainaNaigh
  • RaviGunasekaran
  • gopasruhafoni

Who's online

There are currently 0 users and 1 guest online.