From time to time I come across PostgreSQL databases that I have to interact with. But the command syntax is somewhat different than what I'm used to from other databases like MSSQL or MySQL. This is a collection of commands I use, but often forget.

psql

$ psql -U user -d dbname -c "# SQL command" -f ./script.sql

Commands

Select database

db=# \c databasename

List tables in current database

db=# \dt

Show all available commands

db=# \?