PostgreSQL console

Useful Commands

Here are a few commands that can help you get an idea of your current environment:

  • \?: Get a full list of psql commands, including those not listed here.
  • \h: Get help on SQL commands. You can follow this with a specific command to get help with the syntax.
  • \q: Quit the psql program and exit to the Linux prompt.
  • \d: List available tables, views, and sequences in current database.
  • \du: List available roles
  • \dp: List access privileges
  • \dt: List tables
  • \l: List databases
  • \c: Connect to a different database. Follow this by the database name.
  • \password: Change the password for the username that follows.
  • \conninfo: Get information about the current database and connection.