m-chrzan.xyz
aboutsummaryrefslogtreecommitdiff
path: root/postgres.md
diff options
context:
space:
mode:
authorMarcin Chrzanowski <m@m-chrzan.xyz>2026-09-17 10:07:34 +0200
committerMarcin Chrzanowski <m@m-chrzan.xyz>2026-09-17 10:07:34 +0200
commit03f12dc1dc3352d907944f9ac1ffd78f2f8f955a (patch)
tree49f0f174d8cfd01c600e4bbe2729b2a30e7d5a59 /postgres.md
parente875845f511d04d7ff9d41ddf767233953ebaf46 (diff)
Add postgres commands
Diffstat (limited to 'postgres.md')
-rw-r--r--postgres.md14
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>