Last active
August 29, 2015 13:57
-
-
Save chris-ramon/9353560 to your computer and use it in GitHub Desktop.
postgresql notes
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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