5/9/2016 - 10:07 AM

basic commands

basic commands

\list or \l: list all databases
\dt: list all tables in the current database

connect to database:
sudo -u postgres psql databasename

exit psql:

change password:
\password postgres

drop database:
sudo -u postgres dropdb DB-NAME

load dump:
psql dbname < infile

dump data:
pg_dump dbname > outfile

login as 'postgres':
sudo -u postgres -i

load dump as postgres user:
sudo -u postgres psql db-name < path/to/file.sql