Skip to content

Instantly share code, notes, and snippets.

@jbgo
Created August 24, 2012 15:22
Show Gist options
  • Save jbgo/3451943 to your computer and use it in GitHub Desktop.
Save jbgo/3451943 to your computer and use it in GitHub Desktop.
PostgreSQL Cheatsheet

This is still a work in progress. I'm just adding things as I come across them.

Common command line tasks

Create database: createdb db_name

Drop database: dropdb db_name

Connect to database: psql -d db_name

List all databases: psql -l

psql stuff

Get size of database (human readable): select pg_size_pretty(pg_database_size('db_name'))

Show duration of queries: \timing

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