summaryrefslogtreecommitdiffstats
path: root/software/postgres.page
blob: 7d05074e8b09945b192277f6d80549257919ec8b (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34

Start a quick local docker database:

    docker run -p 5432:5432 postgres:latest

Connect (from outside):

    psql -h localhost -w postgres

Dump current schema with something like:

    docker exec 6a018d9d8ef0 pg_dump -U postgres postgres -s | rg -v ^- > schema.sql

Basic status from the psql command line:

    \l+     (list databases)
    \dt+    (describe table)

## Temporary Databases in Tests

Try `pg_tmp`, though it may not work with high concurrency (due to internal
postgres locking), and might need special configuration in CI environments.

Debian also ships with `pg_virtualenv` for temporary databases.

---------

More refs/links:

- https://stackoverflow.com/questions/9604723/alternate-output-format-for-psql
- https://brandur.org/postgres-connections
- https://www.citusdata.com/blog/2017/07/16/customizing-my-postgres-shell-using-psqlrc/
- `bind "^R" em-inc-search-prev`