User Tools

Site Tools


postgresql

Table of Contents

PostgreSQL

Cheatsheet

# install package
apt install postgresql

# connect
psql -h <hostname> -p 5432 -U <username> -d <dbname> -W

\l  # list databases
\c <dbname>  # connect to a database
\dt  # list tables

# dump
pg_dump -h <hostname> -p 5432 -U postgre -W -F t <dbname> > ./<dumpname>.tar

# restore
pg_restore -d <dbname> ./<dumpname>.tar -c -U <username> -h <hostname> -p 5432
postgresql.txt · Last modified: 2020/05/02 09:34 (external edit)