Skip to content

Latest commit

 

History

History

pgsql

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 

PGSQL Docker Guide

Some basic commands to use pgsql docker container

🐳 Docker-Hub

⏩ Running a sample

docker-compose up

To stop and remove all containers of the sample application run:

docker-compose down

To stop and remove all containers with Volume of the sample application run:

docker-compose down -v

✨ PGSQL Config

  • database (Created Default)- postgres
  • username - postgres
  • password - Passw0rd.
  • port - 5432

  • database (Created using Docker compose) - rajawat
  • username - postgres
  • password - Passw0rd.
  • port - 5432

🎓 PGSQL Commands

  1. Run the following command to open the pgsql client terminal
docker exec -it pg_container psql -h localhost -U postgres
  1. To See list of database:
\l
  1. Create database command
create database lks;
  1. Change database context command
\c lks
  1. List all tables in database
\dt
  1. Drop database command
drop database lks;
  1. To quit the database;
quit
  1. To Take the database backup;
pg_dump -U postgres "DbName" > dbbackup
or
pg_dump -U postgres "DbName" > dbbackup.sql
  1. To restore the database backup;
psql -U postgres "DbName" < dbbackup
or
psql -U postgres "DbName" < dbbackup.sql

Author

👤 RajawatBanna