Skip to content

Instantly share code, notes, and snippets.

@vanderhoop
Created February 2, 2015 14:28
Show Gist options
  • Save vanderhoop/da99588689a3b6e6723a to your computer and use it in GitHub Desktop.
Save vanderhoop/da99588689a3b6e6723a to your computer and use it in GitHub Desktop.

Postgres Console Commands

From the Terminal

  • psql opens the postgres console
  • psql -d some_database_name -f some_sql_file.sql executes the SQL in the given file within the database specified

Within the Postgres Console

  • \q quits the postgres console
  • \l lists all databases
  • \c database_name connects you to database_name
  • \d lists all tables of current database

When Connected To A Database

SELECT * FROM some_table_name; will show all of the records for the given table name

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