Skip to content

Instantly share code, notes, and snippets.

@chris-ramon
Last active August 29, 2015 13:57
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save chris-ramon/9353560 to your computer and use it in GitHub Desktop.
Save chris-ramon/9353560 to your computer and use it in GitHub Desktop.
postgresql notes
# describe table
SELECT attname, attnotnull FROM pg_attribute,pg_class WHERE attrelid=pg_class.oid AND relname='uploads' AND attstattarget <>0;
# start process
postgres -D /usr/local/var/postgres
# list roles
\du
# list tables
\dt
# list databases
\l
# create database fresh postegresql installation with homebrew
# then psql will work
createdb
# create db
createdb myapp_dev
# remove db
dropdb myapp_dev
# list databases
psql -U pgadmin -l
# drop db
dropdb 'database name'
# create role
create role role_name with createdb login password 'qwertyuiop';
# list databases
psql -U chris -l
# logging with user usser to database called db_name
psql -U usser db_name
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment