Postgres Cheatsheet
Access
sudo su - postgres
psql -U postgres -d postgres
or
sudo -u postgres psql -U postgres -d postgres
Command lines
\list or \l: list all databases
\connect databasename or \c databasename
\dt: list all tables in the current database
Backup: pgdump databasename > backup_file.bak
Restore: psql emptydatabasename < backup_file.bak
References: https://www.digitalocean.com/community/tutorials/how-to-backup-postgresql-databases-on-an-ubuntu-vps
Written by Débora Fernandes
Related protips
Have a fresh tip? Share with Coderwall community!
Post
Post a tip
Best
#Postgres
Authors
Sponsored by #native_company# — Learn More
#native_title#
#native_desc#