PostgreSQL
PostgreSQL database administration with psql. Query data, manage users, backups, and server configuration.
103 commands
Browse by Topic
Getting Started
Quick setup and installation
Connection
Connecting to databases
Meta Commands
psql meta commands
Backup/Restore
pg_dump & pg_restore
Import/Export
Data import & export
Administration
Database administration
Query Analysis
Query optimization
Server
Server management
Performance
Performance tuning
Replication
Replication & HA
Users & Roles
User management, roles, grants & permissions
Run PostgreSQL with Docker
Start PostgreSQL server in a Docker container on port 5432
Connect to PostgreSQL
Open interactive psql session in the running container
List databases
List all databases in PostgreSQL
Connect to database
Connect with host, user, and database.
Connect with URL
Connect using connection string.
Connect with SSL
Connect with SSL required.
Execute and exit
Run single command and exit.
Run SQL file
Execute SQL file against database.
Connection info
Display current connection info (in psql).
List databases
List all databases.
Connect to database
Switch to another database.
List tables
List tables in current schema.
List all tables
List tables in all schemas.
Describe table
Show table structure.
List schemas
List all schemas.
List indexes
List indexes.
List functions
List functions.
List roles
List users/roles.
Show search path
Display current schema search path.
Dump database
Export database to SQL file.
Dump compressed
Export in custom compressed format.
Dump table
Export specific table.
Dump schema only
Export schema without data.
Dump data only
Export data without schema.
Dump all databases
Export all databases including roles.
Restore SQL
Restore from SQL file.
Restore custom format
Restore from custom format dump.
Restore parallel
Parallel restore with 4 jobs.
Physical backup with progress
Create compressed tar backup with progress display.
Streaming basebackup
Physical backup with streaming WAL.
Copy to CSV
Export table to CSV file.
Copy from CSV
Import data from CSV file.
COPY (server-side)
Server-side export (requires superuser).
Query to file
Send query results to file.
Import with options
Import with custom delimiter and null handling.
Create database
Create a new database.
Create user
Create a new user with password.
Grant privileges
Grant database privileges to user.
Active connections
View all active connections.
Kill connection
Terminate a backend process by PID.
Database size
Get database size in human-readable format.
Table sizes
List tables by size.
Vacuum analyze
Clean up and update statistics.
Reindex table
Rebuild table indexes.
Explain query
Analyze query execution plan.
Long running queries
Find slow running queries.
Index usage
View index usage statistics.
Table stats
View table statistics.
Lock info
View blocked locks.
Timing on
Enable query timing display.
Start PostgreSQL server
Start the PostgreSQL server instance.
Stop server fast
Stop server, abort connections, shutdown cleanly.
Reload configuration
Reload server configuration without restart.
Replication status
Monitor replication status and lag.
Check if replica
Check if server is in recovery (replica) mode.
Stream WAL logs
Stream WAL logs to archive directory.
View replication slots
List all replication slots and their status.
Create logical publication
Create publication for logical replication.
Discussion
Loading comments...