List databases:
\l
Use a database:
\c db_name
Use schema other than default 'public':
SET search_path = schema_name
List all schema in a database:
select schema_name from information_schema.schemata order by schema_name;
Drop schema in a database:
DROP SCHEMA IF EXISTS schema_name
Show tables in a database:
\dt
Export a database (full path Windows):
pg_dump -U postgres db_name > D:\Downloads\dump.sql
Export a database (full path Linux):
pg_dump -U postgres db_name > /home/username/bak/dump.sql
Export a database (into current directory):
pg_dump -U postgres db_name > dump.sql
Import a full database:
pg_restore -U postgres -d db_name -1 -f dump.sql
Change admin/root user's password:
sudo -u postgres psql
postgres=# \password postgres
Enter new password for user "postgres":
Enter it again: