Skip to content

Instantly share code, notes, and snippets.

Created Jul 22, 2013
What would you like to do?
Learning how to use psql instead of pgAdmin (mostly), and these are the command I want to remember.

Useful psql commands:

How to start/quit the program

  • $ psql database_name: Start psql with database name.
  • \q: Quit psql


  • \l: List all databases
  • \dt: List tables/relations
  • \d <table_name>: List info about a table


  • \x: Turn on extended display (useful for select * from <large_table> type queries or for fields with long fields.)
  • \pset pager: Toggle pager (it gets annoying sometimes)
  • \timing: Turn on/off query time display


  • \h: Help on SQL Syntax
  • \?: List psql slash commands
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment