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
\dt
Describe columns of a postgresql table:
\d <table name>
Display data from multiple tables: