Wednesday, November 23, 2016

Postgres cheatsheet



psql -h <hostname> -U <username> -d <database name> -p 8192
\l - lists all available databases
\c <database name> - example, \c mydb will switch to the database 'mydb'
\d - this will show list of relations including procedures/view, tables, sequence in default schema
\dt - this will show the list of tables in a default schema
\dn - show list of schemas
\dt <schema_name>.* - list tables in a the schema
\df+ <schema_name>.* - list out all procedures

http://alvinalexander.com/blog/post/postgresql/list-postgresql-slash-commands