Useful Postgres Commands

March 9, 2019 ยท View on GitHub

Connecting to Postgres

$ psql postgres

List tables in database

postgres=# \d

List all databases

postgres=# \l

Connect to another database

postgres=# \c dbname

Exit postgres shell

postgres=# \q

Create database

postgres=# CREATE DATABASE databasename;

Drop database

postgres=# DROP DATABASE name;

Find more useful postgres commands here

Contents

  1. 0.1Connecting to Postgres
  2. 0.2List tables in database
  3. 0.3List all databases
  4. 0.4Connect to another database
  5. 0.5Exit postgres shell
  6. 0.6Create database
  7. 0.7Drop database