Programming/PostgreSQL/Databases
< Programming | PostgreSQL
Jump to navigation
Jump to search
Note: Unless otherwise specified, all commands from this section assume you're in the PostgreSQL shell.
General Commands
Creating a New Database
CREATE DATABASE <database_name>;
Deleting a Database
DROP DATABASE <database_name>;
Show All Databases
\l
Load Database
\c <database_name>
Set Database Privileges
GRANT ALL PRIVILEGES ON DATABASE <database_name> TO <user_name>;
Database Backups
Export Database to file
pg_dump -U <user_name> -d <database_name> <file_location>
Import Database from File
pg_restore -U <user_name> -d <database_name> <file_location>