PostgreSQL Command Line Cheat Sheet
sudo -u postgres psql postgres`
postgres=# \l
postgres=# \du
postgres=# CREATE ROLE demorole1 WITH LOGIN ENCRYPTED PASSWORD 'password1' CREATEDB;
postgres=# CREATE ROLE demorole1 WITH LOGIN ENCRYPTED PASSWORD
postgres=# 'password1' CREATEDB CREATEROLE REPLICATION SUPERUSER;
postgres=# ALTER ROLE demorole1 CREATEROLE CREATEDB REPLICATION SUPERUSER;
postgres=# DROP ROLE demorole1;
postgres=# CREATE DATABASE demodb1 WITH OWNER demorole1 ENCODING 'UTF8';
postgres=# GRANT ALL PRIVILEGES ON DATABASE demodb1 TO demorole1;
postgres=# DROP DATABASE demodb1;
postgres=# \c <databasename>
postgres=# \dt
postgres=# \d <tablename>
$ pg_dump <databasename> > <outfile>