Postgresql CMD For General Tasks
Postgresql CMD For General Tasks
========
General
==============
1. Connect to PostgreSQL:
2. Create a Database:
3. Create a User:
4. Grant Privileges:
5. List Databases:
\l
6. List Tables:
-- Set path:
\dt
7. Describe a Table:
\d table_name
8. Backup Database:
SELECT version();
tail -f /var/log/postgresql/postgresql.log
=================================
Creating and grant user access:
------ ------------------
\du
\dp table_name
SHOW ROLE;
============
Database Backup:
==================
Backup Entire Database:
Backup Schema:
--Base Backup:
---------------
pg_basebackup -U <username> -h <hostname> -p <port> -D /path/to/backup
This creates a base backup of the entire PostgreSQL data directory.
Database Restore:
==================
Restore Entire Database:
Restore Schema:
==============