Skip to content

Instantly share code, notes, and snippets.

@pohzipohzi
Created May 12, 2019 01:53
Show Gist options
  • Save pohzipohzi/7fcaf4aab174c8eba75fef1ad8d1dc9d to your computer and use it in GitHub Desktop.
Save pohzipohzi/7fcaf4aab174c8eba75fef1ad8d1dc9d to your computer and use it in GitHub Desktop.
cheatsheet for some common postgres commands

Postgres Cheatsheet

pg_ctl

pg_ctl init -D cluster
pg_ctl -D cluster -l cluster/logfile start
pg_ctl -D cluster restart
pg_ctl -D cluster promote

create

createdb $USER
createuser -s postgres

psql

psql
psql DBNAME USERNAME
psql -f dvdrental/restore.sql

psql command line

\l list databases
\dt show tables
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment