diff options
| -rw-r--r-- | postgres.md | 14 |
1 files changed, 14 insertions, 0 deletions
diff --git a/postgres.md b/postgres.md index ddca2e5..4ac13a2 100644 --- a/postgres.md +++ b/postgres.md @@ -10,8 +10,13 @@ Default user, db: `postgres` - `\c[onnect]`: connects to a database, new server (can specify dbname, username, host, port, etc., use `-` to leave unspecfied) +- `\l[ist]`: list databases. - `\dt`: list tables - There's a bunch of complicated `\d*` commands +- `\o <file>`: output query outputs to file. Empty files returns to outputting to + CLI. +- `\pset format <format>`: sets output format. `aligned` is the default. Can use + e.g. `csv` for outputting to files that can be easily opened. ## User management @@ -33,3 +38,12 @@ Change password: # delete db dropdb mypgdatabase + +Or in `psql`: + + CREATE DATABASE <dbname>; + +## Backup/dumping + + # Can supply password with PGPASSWORD env var + pg_dump [-U username] [-h hostname] [-p port] [-t table_pattern] <database> |