PostgreSQL Commands
PostgreSQL database management commands and psql utilities
19 commands found
/ to searchEscto clear
psql
PostgreSQL interactive terminal
psql -U postgrescreatedb
Create a new PostgreSQL database
createdb myappdropdb
Remove a PostgreSQL database
dropdb myapppg_dump
Backup a PostgreSQL database
pg_dump mydb > backup.sqlpg_restore
Restore a PostgreSQL database from archive
pg_restore -d mydb backup.dumppg_dumpall
Backup all PostgreSQL databases
pg_dumpall > all_databases.sqlcreateuser
Create a new PostgreSQL user
createuser myuserdropuser
Remove a PostgreSQL user
dropuser myuser\l
List all databases in psql
\l\c
Connect to a database in psql
\c mydb\dt
List tables in current database
\dt\d
Describe table structure
\d users\du
List PostgreSQL users/roles
\du\i
Execute SQL from file in psql
\i script.sql\timing
Toggle query execution timing
\timing\x
Toggle expanded display mode
\xvacuumdb
Garbage-collect and analyze PostgreSQL database
vacuumdb mydbreindexdb
Rebuild PostgreSQL database indexes
reindexdb mydbpg_ctl
Control PostgreSQL server
pg_ctl start -D /var/lib/postgresql/data