Skip to content

Instantly share code, notes, and snippets.

@abadongutierrez
Last active March 4, 2016 21:53
Show Gist options
  • Save abadongutierrez/7f47af648bf0b81b7125 to your computer and use it in GitHub Desktop.
Save abadongutierrez/7f47af648bf0b81b7125 to your computer and use it in GitHub Desktop.
Useful PSQL Commands

List databases that match a pattern:

psql -c "\l" | grep <pattern>

Drop a database from the command line:

psql -c "drop database <database>"

Describe a table from the command line:

psql -d <database> -c "\d <schema>.<table>"

Inside psql

\l - list databases
\dt - list tables
\d <table> - describe table

List tables in schema:

\dt schema.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment