From 03f12dc1dc3352d907944f9ac1ffd78f2f8f955a Mon Sep 17 00:00:00 2001 From: Marcin Chrzanowski Date: Thu, 17 Sep 2026 10:07:34 +0200 Subject: Add postgres commands --- postgres.md | 14 ++++++++++++++ 1 file changed, 14 insertions(+) (limited to 'postgres.md') 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 `: output query outputs to file. Empty files returns to outputting to + CLI. +- `\pset 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 ; + +## Backup/dumping + + # Can supply password with PGPASSWORD env var + pg_dump [-U username] [-h hostname] [-p port] [-t table_pattern] -- cgit v1.2.3