Some of the common postgres related commands
Logging into local Postgres server
sudo psql -U <username>
sudo psql -U postgres
Creating a new database. (Note: following command need to run after #1)
create database <db_name>;
create database test_db;
Dropping a database. (Note: following command need to run after #1)
drop database <db_name>;
drop database test_db;
Take complete backup dump of a database.
pg_dump --no-owner -h <host_ip/endpoint> -p <port> -U <username> <db_name> > <file_path>
pg_dump --no-owner -h 00.00.00.00 -p 5432 -U postgres uat_db > test_dump.sql
Restoring the dump to an existing new database in local.
sudo psql -U <username> -d <db_name> < <file_path>
sudo psql -U postgres -d <test_db> < test_dump.sql