openskills.info
← All tool references

open-source

PostgreSQL

Open, provenance-stamped install, usage, command, settings and footprint reference for PostgreSQL, paired with the PostgreSQL Fundamentals course.

Distribution
open-source
Licence
Not published
Reference version
Authoritative source snapshot 2026-07-30
Current upstream version
Not published
Provenance
Captured source data

Install by Target

Official or upstream install sources only. Third-party sources are labelled with their publisher.

Linux Debian family

  • apt

    set -eu
    printf '#!/bin/sh\nexit 101\n' > /usr/sbin/policy-rc.d
    chmod 755 /usr/sbin/policy-rc.d
    apt-get update
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl gpg
    curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc -o /tmp/pgdg-signing-key.asc
    gpg --batch --yes --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg /tmp/pgdg-signing-key.asc
    printf 'deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] https://apt.postgresql.org/pub/repos/apt noble-pgdg main\n' > /etc/apt/sources.list.d/pgdg.list
    apt-get update
    DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends postgresql-18=18.6-1.pgdg24.04+2 postgresql-client-18=18.6-1.pgdg24.04+2
    psql --version

    verified on linux-amd64-proxmox, 2026-10-24

RPM family

  • dnf

    set -eu
    dnf install -y https://download.postgresql.org/pub/repos/yum/reporpms/EL-9-x86_64/pgdg-redhat-repo-latest.noarch.rpm
    dnf -qy module disable postgresql
    dnf install -y postgresql18-server
    /usr/pgsql-18/bin/postgresql-18-setup initdb
    /usr/pgsql-18/bin/psql --version

    unverified

macOS

  • brew

    set -eu
    brew install postgresql@18
    "$(brew --prefix postgresql@18)/bin/psql" --version

    unverified

Windows

  • binary

    No install command is published yet.

    unverified

Docker

  • docker

    docker run --rm postgres@sha256:edb0c08dc33befd0262ab3b5cf1c4f3f8cfd8b09e88c05b45adee29d6761ddb6 postgres --version

    verified on linux-amd64-proxmox, 2026-10-24

Kubernetes

The PostgreSQL project publishes no official Helm chart, operator or manifest for Kubernetes; its documentation covers the server, not an orchestrator. Community operators and distributions exist (for example CloudNativePG) but are third-party products with their own release cycle and are not offered as a default here.

Quickstart Lab

Open Lab variants from Scenarios. Commands are what ran; never retyped.

Linux

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_0'
set -eu
printf '#!/bin/sh\nexit 101\n' > /usr/sbin/policy-rc.d
chmod 755 /usr/sbin/policy-rc.d
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends ca-certificates curl gpg
curl -fsSL https://www.postgresql.org/media/keys/ACCC4CF8.asc -o /tmp/pgdg-signing-key.asc
gpg --batch --yes --dearmor -o /usr/share/keyrings/postgresql-archive-keyring.gpg /tmp/pgdg-signing-key.asc
printf 'deb [signed-by=/usr/share/keyrings/postgresql-archive-keyring.gpg] https://apt.postgresql.org/pub/repos/apt noble-pgdg main\n' > /etc/apt/sources.list.d/pgdg.list
apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y --no-install-recommends postgresql-18=18.6-1.pgdg24.04+2 postgresql-client-18=18.6-1.pgdg24.04+2
psql --version
OPENSKILLS_LAB_STEP_0
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_1'
set -eu
if ! pg_lsclusters -h | grep -q "^18 main"; then pg_createcluster 18 main >/dev/null 2>&1; fi
pg_ctlcluster 18 main start >/dev/null 2>&1
for attempt in $(seq 1 30); do
  if runuser -u postgres -- pg_isready -q; then break; fi
  sleep 1
done
runuser -u postgres -- pg_isready -q
printf 'Fixture ready\n'
OPENSKILLS_LAB_STEP_1
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_2'
runuser -u postgres -- createdb -U postgres openskills_demo
OPENSKILLS_LAB_STEP_2
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_3'
runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "CREATE TABLE notes (id serial PRIMARY KEY, body text NOT NULL)"
OPENSKILLS_LAB_STEP_3
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_4'
runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "INSERT INTO notes (body) VALUES ('first'), ('second')"
OPENSKILLS_LAB_STEP_4
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_5'
runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "SELECT body FROM notes ORDER BY id"
OPENSKILLS_LAB_STEP_5
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_6'
runuser -u postgres -- pg_dump -U postgres --schema-only openskills_demo
OPENSKILLS_LAB_STEP_6
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_7'
runuser -u postgres -- dropdb -U postgres openskills_demo
OPENSKILLS_LAB_STEP_7
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_8'
set -eu
pg_dropcluster --stop 18 main >/dev/null 2>&1
rm -f /tmp/openskills_demo.dump /tmp/pgdg-signing-key.asc
printf 'Sandbox removed\n'
OPENSKILLS_LAB_STEP_8
)"

verified on linux-amd64-proxmox, 2026-10-24

Docker

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_0'
docker run --rm postgres@sha256:edb0c08dc33befd0262ab3b5cf1c4f3f8cfd8b09e88c05b45adee29d6761ddb6 postgres --version
OPENSKILLS_LAB_STEP_0
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_1'
set -eu
docker rm -f pgdemo >/dev/null 2>&1 || true
docker run -d --name pgdemo -e POSTGRES_PASSWORD=openskills-demo postgres@sha256:edb0c08dc33befd0262ab3b5cf1c4f3f8cfd8b09e88c05b45adee29d6761ddb6 >/dev/null
for attempt in $(seq 1 60); do
  if [ "$(docker logs pgdemo 2>&1 | grep -c "ready to accept connections")" -ge 2 ]; then break; fi
  sleep 1
done
docker exec pgdemo pg_isready -q
printf 'Fixture ready\n'
OPENSKILLS_LAB_STEP_1
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_2'
docker exec pgdemo createdb -U postgres openskills_demo
OPENSKILLS_LAB_STEP_2
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_3'
docker exec pgdemo psql -X -At -U postgres -d openskills_demo -c "CREATE TABLE notes (id serial PRIMARY KEY, body text NOT NULL)"
OPENSKILLS_LAB_STEP_3
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_4'
docker exec pgdemo psql -X -At -U postgres -d openskills_demo -c "INSERT INTO notes (body) VALUES ('first'), ('second')"
OPENSKILLS_LAB_STEP_4
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_5'
docker exec pgdemo psql -X -At -U postgres -d openskills_demo -c "SELECT body FROM notes ORDER BY id"
OPENSKILLS_LAB_STEP_5
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_6'
docker exec pgdemo pg_dump -U postgres --schema-only openskills_demo
OPENSKILLS_LAB_STEP_6
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_7'
docker exec pgdemo dropdb -U postgres openskills_demo
OPENSKILLS_LAB_STEP_7
)"

sh -c "$(cat <<'OPENSKILLS_LAB_STEP_8'
docker rm -f pgdemo >/dev/null
printf 'Sandbox removed\n'
OPENSKILLS_LAB_STEP_8
)"

verified on linux-amd64-proxmox, 2026-10-24

Helm

The PostgreSQL project publishes no official Helm chart, operator or manifest for Kubernetes; its documentation covers the server, not an orchestrator. Community operators and distributions exist (for example CloudNativePG) but are third-party products with their own release cycle and are not offered as a default here.

Usage recipes

Lifecycle recipes with a Target access preamble. Choose a Target to see the command that runs there.

Configure

Create a database from the shell.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- createdb -U postgres openskills_demo
  • RPM family
    runuser -u postgres -- createdb -U postgres openskills_demo
  • macOS
    env createdb -U postgres openskills_demo
  • Windows
    cmd /c createdb -U postgres openskills_demo
  • Docker
    docker exec pgdemo createdb -U postgres openskills_demo

Create a table.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "CREATE TABLE notes (id serial PRIMARY KEY, body text NOT NULL)"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "CREATE TABLE notes (id serial PRIMARY KEY, body text NOT NULL)"
  • macOS
    env psql -X -At -U postgres -d openskills_demo -c "CREATE TABLE notes (id serial PRIMARY KEY, body text NOT NULL)"
  • Windows
    cmd /c psql -X -At -U postgres -d openskills_demo -c "CREATE TABLE notes (id serial PRIMARY KEY, body text NOT NULL)"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -d openskills_demo -c "CREATE TABLE notes (id serial PRIMARY KEY, body text NOT NULL)"

Persist a new work_mem value with ALTER SYSTEM.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -c "ALTER SYSTEM SET work_mem = '8MB'"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -c "ALTER SYSTEM SET work_mem = '8MB'"
  • macOS
    env psql -X -At -U postgres -c "ALTER SYSTEM SET work_mem = '8MB'"
  • Windows
    cmd /c psql -X -At -U postgres -c "ALTER SYSTEM SET work_mem = '8MB'"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -c "ALTER SYSTEM SET work_mem = '8MB'"

Create a role that cannot log in, to hold privileges.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -c "CREATE ROLE app_reader NOLOGIN"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -c "CREATE ROLE app_reader NOLOGIN"
  • macOS
    env psql -X -At -U postgres -c "CREATE ROLE app_reader NOLOGIN"
  • Windows
    cmd /c psql -X -At -U postgres -c "CREATE ROLE app_reader NOLOGIN"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -c "CREATE ROLE app_reader NOLOGIN"

Inspect

Print the psql client version.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql --version
  • RPM family
    runuser -u postgres -- psql --version
  • macOS
    env psql --version
  • Windows
    cmd /c psql --version
  • Docker
    docker exec pgdemo psql --version

Check whether the server accepts connections.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- pg_isready
  • RPM family
    runuser -u postgres -- pg_isready
  • macOS
    env pg_isready
  • Windows
    cmd /c pg_isready
  • Docker
    docker exec pgdemo pg_isready

Ask the server for its version.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -c "SHOW server_version"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -c "SHOW server_version"
  • macOS
    env psql -X -At -U postgres -c "SHOW server_version"
  • Windows
    cmd /c psql -X -At -U postgres -c "SHOW server_version"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -c "SHOW server_version"

List the databases of the server.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -l
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -l
  • macOS
    env psql -X -At -U postgres -l
  • Windows
    cmd /c psql -X -At -U postgres -l
  • Docker
    docker exec pgdemo psql -X -At -U postgres -l

Count the rows of a table.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "SELECT count(*) FROM notes"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "SELECT count(*) FROM notes"
  • macOS
    env psql -X -At -U postgres -d openskills_demo -c "SELECT count(*) FROM notes"
  • Windows
    cmd /c psql -X -At -U postgres -d openskills_demo -c "SELECT count(*) FROM notes"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -d openskills_demo -c "SELECT count(*) FROM notes"

Describe a table with the psql meta-command.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -U postgres -d openskills_demo -c "\d notes"
  • RPM family
    runuser -u postgres -- psql -X -U postgres -d openskills_demo -c "\d notes"
  • macOS
    env psql -X -U postgres -d openskills_demo -c "\d notes"
  • Windows
    cmd /c psql -X -U postgres -d openskills_demo -c "\d notes"
  • Docker
    docker exec pgdemo psql -X -U postgres -d openskills_demo -c "\d notes"

Report the size of a database in readable units.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -c "SELECT pg_size_pretty(pg_database_size('openskills_demo'))"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -c "SELECT pg_size_pretty(pg_database_size('openskills_demo'))"
  • macOS
    env psql -X -At -U postgres -c "SELECT pg_size_pretty(pg_database_size('openskills_demo'))"
  • Windows
    cmd /c psql -X -At -U postgres -c "SELECT pg_size_pretty(pg_database_size('openskills_demo'))"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -c "SELECT pg_size_pretty(pg_database_size('openskills_demo'))"

List what a custom-format dump archive contains.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- pg_restore -l /tmp/openskills_demo.dump
  • RPM family
    runuser -u postgres -- pg_restore -l /tmp/openskills_demo.dump
  • macOS
    env pg_restore -l /tmp/openskills_demo.dump
  • Windows
    cmd /c pg_restore -l /tmp/openskills_demo.dump
  • Docker
    docker exec pgdemo pg_restore -l /tmp/openskills_demo.dump

Show the value a session sees for one setting.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -c "SHOW work_mem"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -c "SHOW work_mem"
  • macOS
    env psql -X -At -U postgres -c "SHOW work_mem"
  • Windows
    cmd /c psql -X -At -U postgres -c "SHOW work_mem"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -c "SHOW work_mem"

Tell a primary from a standby.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -c "SELECT pg_is_in_recovery()"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -c "SELECT pg_is_in_recovery()"
  • macOS
    env psql -X -At -U postgres -c "SELECT pg_is_in_recovery()"
  • Windows
    cmd /c psql -X -At -U postgres -c "SELECT pg_is_in_recovery()"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -c "SELECT pg_is_in_recovery()"

Operate

Vacuum a table and refresh its planner statistics.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "VACUUM (ANALYZE) notes"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "VACUUM (ANALYZE) notes"
  • macOS
    env psql -X -At -U postgres -d openskills_demo -c "VACUUM (ANALYZE) notes"
  • Windows
    cmd /c psql -X -At -U postgres -d openskills_demo -c "VACUUM (ANALYZE) notes"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -d openskills_demo -c "VACUUM (ANALYZE) notes"

Rebuild every index of a table.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "REINDEX TABLE notes"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "REINDEX TABLE notes"
  • macOS
    env psql -X -At -U postgres -d openskills_demo -c "REINDEX TABLE notes"
  • Windows
    cmd /c psql -X -At -U postgres -d openskills_demo -c "REINDEX TABLE notes"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -d openskills_demo -c "REINDEX TABLE notes"

Print the schema of a database as SQL without any data.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- pg_dump -U postgres --schema-only openskills_demo
  • RPM family
    runuser -u postgres -- pg_dump -U postgres --schema-only openskills_demo
  • macOS
    env pg_dump -U postgres --schema-only openskills_demo
  • Windows
    cmd /c pg_dump -U postgres --schema-only openskills_demo
  • Docker
    docker exec pgdemo pg_dump -U postgres --schema-only openskills_demo

Ask the server to re-read its configuration files.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -c "SELECT pg_reload_conf()"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -c "SELECT pg_reload_conf()"
  • macOS
    env psql -X -At -U postgres -c "SELECT pg_reload_conf()"
  • Windows
    cmd /c psql -X -At -U postgres -c "SELECT pg_reload_conf()"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -c "SELECT pg_reload_conf()"

Change

Insert two rows in one statement.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "INSERT INTO notes (body) VALUES ('first'), ('second')"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "INSERT INTO notes (body) VALUES ('first'), ('second')"
  • macOS
    env psql -X -At -U postgres -d openskills_demo -c "INSERT INTO notes (body) VALUES ('first'), ('second')"
  • Windows
    cmd /c psql -X -At -U postgres -d openskills_demo -c "INSERT INTO notes (body) VALUES ('first'), ('second')"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -d openskills_demo -c "INSERT INTO notes (body) VALUES ('first'), ('second')"

Restore a custom-format dump into an empty database.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- pg_restore -U postgres -d openskills_restore /tmp/openskills_demo.dump
  • RPM family
    runuser -u postgres -- pg_restore -U postgres -d openskills_restore /tmp/openskills_demo.dump
  • macOS
    env pg_restore -U postgres -d openskills_restore /tmp/openskills_demo.dump
  • Windows
    cmd /c pg_restore -U postgres -d openskills_restore /tmp/openskills_demo.dump
  • Docker
    docker exec pgdemo pg_restore -U postgres -d openskills_restore /tmp/openskills_demo.dump

Let a role read a table.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "GRANT SELECT ON notes TO app_reader"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "GRANT SELECT ON notes TO app_reader"
  • macOS
    env psql -X -At -U postgres -d openskills_demo -c "GRANT SELECT ON notes TO app_reader"
  • Windows
    cmd /c psql -X -At -U postgres -d openskills_demo -c "GRANT SELECT ON notes TO app_reader"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -d openskills_demo -c "GRANT SELECT ON notes TO app_reader"

Troubleshoot

Show the plan the server chooses for a query.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "EXPLAIN SELECT * FROM notes WHERE id = 1"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -d openskills_demo -c "EXPLAIN SELECT * FROM notes WHERE id = 1"
  • macOS
    env psql -X -At -U postgres -d openskills_demo -c "EXPLAIN SELECT * FROM notes WHERE id = 1"
  • Windows
    cmd /c psql -X -At -U postgres -d openskills_demo -c "EXPLAIN SELECT * FROM notes WHERE id = 1"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -d openskills_demo -c "EXPLAIN SELECT * FROM notes WHERE id = 1"

Count sessions that are running a statement right now.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- psql -X -At -U postgres -c "SELECT count(*) FROM pg_stat_activity WHERE state = 'active'"
  • RPM family
    runuser -u postgres -- psql -X -At -U postgres -c "SELECT count(*) FROM pg_stat_activity WHERE state = 'active'"
  • macOS
    env psql -X -At -U postgres -c "SELECT count(*) FROM pg_stat_activity WHERE state = 'active'"
  • Windows
    cmd /c psql -X -At -U postgres -c "SELECT count(*) FROM pg_stat_activity WHERE state = 'active'"
  • Docker
    docker exec pgdemo psql -X -At -U postgres -c "SELECT count(*) FROM pg_stat_activity WHERE state = 'active'"

Remove

Drop a database from the shell.

verified on linux-amd64-proxmox, 2026-10-24

Linux Debian familyRPM familymacOSWindowsDocker

  • Linux Debian family
    runuser -u postgres -- dropdb -U postgres openskills_demo
  • RPM family
    runuser -u postgres -- dropdb -U postgres openskills_demo
  • macOS
    env dropdb -U postgres openskills_demo
  • Windows
    cmd /c dropdb -U postgres openskills_demo
  • Docker
    docker exec pgdemo dropdb -U postgres openskills_demo

Commands

  • psql
    • --command
    • --dbname
    • --file
    • --list
    • --set
    • --version
    • --no-psqlrc
    • --help
    • --echo-all
    • --echo-errors
    • --echo-queries
    • --echo-hidden
    • --log-file
    • --no-readline
    • --output
    • --quiet
    • --single-step
    • --single-line
    • --no-align
    • --csv
    • --field-separator
    • --html
    • --pset
    • --record-separator
    • --tuples-only
    • --table-attr
    • --expanded
    • --field-separator-zero
    • --record-separator-zero
    • --host
    • --port
    • --username
    • --no-password
    • --password
  • pg_dump
    • --file
    • --format
    • --jobs
    • --verbose
    • --version
    • --compress
    • --lock-wait-timeout
    • --no-sync
    • --sync-method
    • --data-only
    • --large-objects
    • --blobs
    • --no-large-objects
    • --no-blobs
    • --clean
    • --create
    • --extension
    • --encoding
    • --schema
    • --exclude-schema
    • --no-owner
    • --schema-only
    • --superuser
    • --table
    • --exclude-table
    • --no-privileges
    • --binary-upgrade
    • --column-inserts
    • --disable-dollar-quoting
    • --disable-triggers
    • --enable-row-security
    • --exclude-extension
    • --exclude-table-and-children
    • --exclude-table-data
    • --exclude-table-data-and-children
    • --extra-float-digits
    • --filter
    • --if-exists
    • --include-foreign-data
    • --inserts
    • --load-via-partition-root
    • --no-comments
    • --no-data
    • --no-policies
    • --no-publications
    • --no-schema
    • --no-security-labels
    • --no-statistics
    • --no-subscriptions
    • --no-table-access-method
    • --no-tablespaces
    • --no-toast-compression
    • --no-unlogged-table-data
    • --on-conflict-do-nothing
    • --quote-all-identifiers
    • --restrict-key
    • --rows-per-insert
    • --section
    • --sequence-data
    • --serializable-deferrable
    • --snapshot
    • --statistics
    • --statistics-only
    • --strict-names
    • --table-and-children
    • --use-set-session-authorization
    • --dbname
    • --host
    • --port
    • --username
    • --no-password
    • --password
    • --role
  • pg_restore
    • --dbname
    • --file
    • --format
    • --list
    • --verbose
    • --version
    • --data-only
    • --clean
    • --create
    • --exit-on-error
    • --index
    • --jobs
    • --use-list
    • --schema
    • --exclude-schema
    • --no-owner
    • --function
    • --schema-only
    • --superuser
    • --table
    • --trigger
    • --no-privileges
    • --single-transaction
    • --disable-triggers
    • --enable-row-security
    • --filter
    • --if-exists
    • --no-comments
    • --no-data
    • --no-data-for-failed-tables
    • --no-policies
    • --no-publications
    • --no-schema
    • --no-security-labels
    • --no-statistics
    • --no-subscriptions
    • --no-table-access-method
    • --no-tablespaces
    • --restrict-key
    • --section
    • --statistics
    • --statistics-only
    • --strict-names
    • --transaction-size
    • --use-set-session-authorization
    • --host
    • --port
    • --username
    • --no-password
    • --password
    • --role
  • pg_dumpall
    • --file
    • --verbose
    • --version
    • --lock-wait-timeout
    • --data-only
    • --clean
    • --encoding
    • --globals-only
    • --no-owner
    • --roles-only
    • --schema-only
    • --superuser
    • --tablespaces-only
    • --no-privileges
    • --binary-upgrade
    • --column-inserts
    • --disable-dollar-quoting
    • --disable-triggers
    • --exclude-database
    • --extra-float-digits
    • --filter
    • --if-exists
    • --inserts
    • --load-via-partition-root
    • --no-comments
    • --no-data
    • --no-policies
    • --no-publications
    • --no-role-passwords
    • --no-schema
    • --no-security-labels
    • --no-statistics
    • --no-subscriptions
    • --no-sync
    • --no-table-access-method
    • --no-tablespaces
    • --no-toast-compression
    • --no-unlogged-table-data
    • --on-conflict-do-nothing
    • --quote-all-identifiers
    • --restrict-key
    • --rows-per-insert
    • --sequence-data
    • --statistics
    • --statistics-only
    • --use-set-session-authorization
    • --dbname
    • --host
    • --database
    • --port
    • --username
    • --no-password
    • --password
    • --role
  • pg_basebackup
    • --pgdata
    • --format
    • --incremental
    • --max-rate
    • --write-recovery-conf
    • --target
    • --tablespace-mapping
    • --waldir
    • --wal-method
    • --gzip
    • --compress
    • --checkpoint
    • --create-slot
    • --label
    • --no-clean
    • --no-sync
    • --progress
    • --slot
    • --verbose
    • --version
    • --manifest-checksums
    • --manifest-force-encode
    • --no-estimate-size
    • --no-manifest
    • --no-slot
    • --no-verify-checksums
    • --sync-method
    • --dbname
    • --host
    • --port
    • --status-interval
    • --username
    • --no-password
    • --password
  • pg_isready
    • --dbname
    • --quiet
    • --version
    • --host
    • --port
    • --timeout
    • --username
  • createdb
    • --tablespace
    • --echo
    • --encoding
    • --locale
    • --lc-collate
    • --lc-ctype
    • --builtin-locale
    • --icu-locale
    • --icu-rules
    • --locale-provider
    • --owner
    • --strategy
    • --template
    • --version
    • --host
    • --port
    • --username
    • --no-password
    • --password
    • --maintenance-db
  • dropdb
    • --echo
    • --force
    • --interactive
    • --version
    • --if-exists
    • --host
    • --port
    • --username
    • --no-password
    • --password
    • --maintenance-db
  • createuser
    • --with-admin
    • --connection-limit
    • --createdb
    • --no-createdb
    • --echo
    • --member-of
    • --role
    • --inherit
    • --no-inherit
    • --login
    • --no-login
    • --with-member
    • --pwprompt
    • --createrole
    • --no-createrole
    • --superuser
    • --no-superuser
    • --valid-until
    • --version
    • --interactive
    • --bypassrls
    • --no-bypassrls
    • --replication
    • --no-replication
    • --host
    • --port
    • --username
    • --no-password
    • --password
  • dropuser
    • --echo
    • --interactive
    • --version
    • --if-exists
    • --host
    • --port
    • --username
    • --no-password
    • --password
  • vacuumdb
    • --all
    • --buffer-usage-limit
    • --dbname
    • --disable-page-skipping
    • --echo
    • --full
    • --freeze
    • --force-index-cleanup
    • --jobs
    • --min-mxid-age
    • --min-xid-age
    • --missing-stats-only
    • --no-index-cleanup
    • --no-process-main
    • --no-process-toast
    • --no-truncate
    • --schema
    • --exclude-schema
    • --parallel
    • --quiet
    • --skip-locked
    • --table
    • --verbose
    • --version
    • --analyze
    • --analyze-only
    • --analyze-in-stages
    • --host
    • --port
    • --username
    • --no-password
    • --password
    • --maintenance-db
  • reindexdb
    • --all
    • --concurrently
    • --dbname
    • --echo
    • --index
    • --jobs
    • --quiet
    • --system
    • --schema
    • --table
    • --tablespace
    • --verbose
    • --version
    • --host
    • --port
    • --username
    • --no-password
    • --password
    • --maintenance-db
  • clusterdb
    • --all
    • --dbname
    • --echo
    • --quiet
    • --table
    • --verbose
    • --version
    • --host
    • --port
    • --username
    • --no-password
    • --password
    • --maintenance-db
  • initdb
    • --auth
    • --auth-host
    • --auth-local
    • --encoding
    • --allow-group-access
    • --icu-locale
    • --icu-rules
    • --data-checksums
    • --locale
    • --lc-collate
    • --lc-monetary
    • --no-locale
    • --builtin-locale
    • --locale-provider
    • --no-data-checksums
    • --pwfile
    • --text-search-config
    • --username
    • --pwprompt
    • --waldir
    • --wal-segsize
    • --set
    • --debug
    • --discard-caches
    • -L
    • --no-clean
    • --no-sync
    • --no-sync-data-files
    • --no-instructions
    • --show
    • --sync-method
    • --sync-only
    • --version
  • pg_ctl
    • --pgdata
    • --silent
    • --timeout
    • --version
    • --wait
    • --no-wait
    • --core-files
    • --log
    • --options
    • --mode
  • pg_upgrade
    • --old-bindir
    • --new-bindir
    • --check
    • --old-datadir
    • --new-datadir
    • --jobs
    • --link
    • --no-sync
    • --old-options
    • --new-options
    • --old-port
    • --new-port
    • --retain
    • --socketdir
    • --username
    • --verbose
    • --version
    • --clone
    • --copy
    • --copy-file-range
    • --no-statistics
    • --set-char-signedness
    • --swap
    • --sync-method
  • postgres
    • -B
    • -C
    • -D
    • -e
    • -F
    • -h
    • -i
    • -k
    • -l
    • -p
    • -s
    • --version
    • --NAME
    • --describe-config
    • -O
    • -P
    • -T
    • -W
    • --single
    • -E
    • -j
    • -r
    • --boot
    • --check
  • pg_config
    • --bindir
    • --docdir
    • --htmldir
    • --includedir
    • --pkgincludedir
    • --includedir-server
    • --libdir
    • --pkglibdir
    • --localedir
    • --mandir
    • --sharedir
    • --sysconfdir
    • --pgxs
    • --configure
    • --cc
    • --cppflags
    • --cflags
    • --cflags_sl
    • --ldflags
    • --ldflags_ex
    • --ldflags_sl
    • --libs
    • --version
  • pg_controldata
    • --version
  • pg_resetwal
    • --force
    • --dry-run
    • --version
    • --commit-timestamp-ids
    • --epoch
    • --next-wal-file
    • --multixact-ids
    • --next-oid
    • --multixact-offset
    • --oldest-transaction-id
    • --next-transaction-id
    • --char-signedness
    • --wal-segsize
  • pg_verifybackup
    • --exit-on-error
    • --format
    • --ignore
    • --manifest-path
    • --no-parse-wal
    • --progress
    • --quiet
    • --skip-checksums
    • --wal-directory
    • --version
  • pg_amcheck
    • --all
    • --database
    • --exclude-database
    • --index
    • --exclude-index
    • --relation
    • --exclude-relation
    • --schema
    • --exclude-schema
    • --table
    • --exclude-table
    • --no-dependent-indexes
    • --no-dependent-toast
    • --no-strict-names
    • --exclude-toast-pointers
    • --on-error-stop
    • --skip
    • --startblock
    • --endblock
    • --checkunique
    • --heapallindexed
    • --parent-check
    • --rootdescend
    • --host
    • --port
    • --username
    • --no-password
    • --password
    • --maintenance-db
    • --echo
    • --jobs
    • --progress
    • --verbose
    • --version
    • --install-missing
  • pg_waldump
    • --bkp-details
    • --block
    • --end
    • --follow
    • --fork
    • --limit
    • --path
    • --quiet
    • --rmgr
    • --relation
    • --start
    • --timeline
    • --version
    • --fullpage
    • --xid
    • --stats
    • --save-fullpage
  • pg_rewind
    • --restore-target-wal
    • --target-pgdata
    • --source-pgdata
    • --source-server
    • --dry-run
    • --no-sync
    • --progress
    • --write-recovery-conf
    • --config-file
    • --debug
    • --no-ensure-shutdown
    • --sync-method
    • --version

Settings

Configuration keys grouped by file or scope. Defaults carry the version they were recorded against.

environment

KeyTypeDefaultChange effectSource
PGHOSTstringruntimesource
PGPORTintegerruntimesource
PGUSERstringruntimesource
PGDATABASEstringruntimesource
PGPASSWORDstringruntimesource
PGPASSFILEstringruntimesource
PGSERVICEstringruntimesource
PGSSLMODEenumruntimesource
PGCONNECT_TIMEOUTintegerruntimesource
PGDATAstringruntimesource

postgresql-conf

KeyTypeDefaultChange effectSource
archive_commandstringreloadsource
archive_modeenumoff (as of 18.6)restartsource
autovacuumbooleantrue (as of 18.6)reloadsource
checkpoint_timeoutinteger300 (as of 18.6)reloadsource
data_directorystringrestartsource
default_transaction_isolationenumread committed (as of 18.6)runtimesource
effective_cache_sizeinteger524288 (as of 18.6)runtimesource
fsyncbooleantrue (as of 18.6)reloadsource
hba_filestringrestartsource
hot_standbybooleantrue (as of 18.6)restartsource
idle_in_transaction_session_timeoutinteger0 (as of 18.6)runtimesource
listen_addressesstringlocalhost (as of 18.6)restartsource
log_destinationstringstderr (as of 18.6)reloadsource
logging_collectorbooleanfalse (as of 18.6)restartsource
log_line_prefixstring%m [%p] (as of 18.6)reloadsource
log_min_duration_statementinteger-1 (as of 18.6)runtimesource
log_statementenumnone (as of 18.6)runtimesource
maintenance_work_meminteger65536 (as of 18.6)runtimesource
max_connectionsinteger100 (as of 18.6)restartsource
max_replication_slotsinteger10 (as of 18.6)restartsource
max_wal_sendersinteger10 (as of 18.6)restartsource
max_wal_sizeinteger1024 (as of 18.6)reloadsource
max_worker_processesinteger8 (as of 18.6)restartsource
min_wal_sizeinteger80 (as of 18.6)reloadsource
password_encryptionenumscram-sha-256 (as of 18.6)runtimesource
portinteger5432 (as of 18.6)restartsource
random_page_coststring4 (as of 18.6)runtimesource
shared_buffersinteger16384 (as of 18.6)restartsource
shared_preload_librariesstringrestartsource
sslbooleanfalse (as of 18.6)reloadsource
statement_timeoutinteger0 (as of 18.6)runtimesource
synchronous_commitenumon (as of 18.6)runtimesource
track_io_timingbooleanfalse (as of 18.6)runtimesource
unix_socket_directoriesstring/var/run/postgresql (as of 18.6)restartsource
wal_compressionenumoff (as of 18.6)runtimesource
wal_levelenumreplica (as of 18.6)restartsource
work_meminteger4096 (as of 18.6)runtimesource

Footprint

Files, directories, services and ports on each OS or provider. Paths are as recorded; unverified nodes stay labelled until Evidence backs them.

Default

Files

  • postgresql-conf

    $PGDATA/postgresql.conf

    Source

  • postgresql-auto-conf

    $PGDATA/postgresql.auto.conf

    Source

  • pg-hba-conf

    $PGDATA/pg_hba.conf

    Source

  • pg-ident-conf

    $PGDATA/pg_ident.conf

    Source

  • pg-version

    $PGDATA/PG_VERSION

    Source

  • postmaster-pid

    $PGDATA/postmaster.pid

    Source

  • debian-postgresql-conf

    /etc/postgresql/18/main/postgresql.conf

    Source

Directories

  • data-directory-debian

    /var/lib/postgresql/18/main

    Source

  • data-directory-docker

    /var/lib/postgresql/18/docker

    Source

  • socket-directory

    /var/run/postgresql

    Source

Feeds

OSV

As of , cached live. Status: cached.

OSV returned 0 records.

These are source records, not a verdict on whether the taught version is affected. Inspect the full OSV record before acting.

    endoflife.date

    As of , cached live. Status: cached.

    endoflife.date returned 33 cycles.

    • Cycle 19

      Released: 2026-11-19

      Latest: 19.0

      End of life: 2031-11-19

    • Cycle 18

      Released: 2025-09-25

      Latest: 18.7

      End of life: 2030-11-14

    • Cycle 17

      Released: 2024-09-26

      Latest: 17.12

      End of life: 2029-11-08

    • Cycle 16

      Released: 2023-09-14

      Latest: 16.16

      End of life: 2028-11-09

    • Cycle 15

      Released: 2022-10-13

      Latest: 15.20

      End of life: 2027-11-11

    • Cycle 14

      Released: 2021-09-30

      Latest: 14.25

      End of life: 2026-11-12

    • Cycle 13

      Released: 2020-09-24

      Latest: 13.23

      End of life: 2025-11-13

    • Cycle 12

      Released: 2019-10-03

      Latest: 12.22

      End of life: 2024-11-21

    • Cycle 11

      Released: 2018-10-18

      Latest: 11.22

      End of life: 2023-11-09

    • Cycle 10

      Released: 2017-10-05

      Latest: 10.23

      End of life: 2022-11-10

    • Cycle 9.6

      Released: 2016-09-29

      Latest: 9.6.24

      End of life: 2021-11-11

    • Cycle 9.5

      Released: 2016-01-07

      Latest: 9.5.25

      End of life: 2021-02-11

    • Cycle 9.4

      Released: 2014-12-18

      Latest: 9.4.26

      End of life: 2020-02-13

    • Cycle 9.3

      Released: 2013-09-09

      Latest: 9.3.25

      End of life: 2018-11-08

    • Cycle 9.2

      Released: 2012-09-10

      Latest: 9.2.24

      End of life: 2017-11-09

    • Cycle 9.1

      Released: 2011-09-12

      Latest: 9.1.24

      End of life: 2016-10-27

    • Cycle 9.0

      Released: 2010-09-20

      Latest: 9.0.23

      End of life: 2015-10-08

    • Cycle 8.4

      Released: 2009-07-01

      Latest: 8.4.22

      End of life: 2014-07-24

    • Cycle 8.3

      Released: 2008-02-04

      Latest: 8.3.23

      End of life: 2013-02-07

    • Cycle 8.2

      Released: 2006-12-05

      Latest: 8.2.23

      End of life: 2011-12-05

    • Cycle 8.1

      Released: 2005-11-08

      Latest: 8.1.23

      End of life: 2010-11-08

    • Cycle 8.0

      Released: 2005-01-19

      Latest: 8.0.26

      End of life: 2010-10-01

    • Cycle 7.4

      Released: 2003-11-17

      Latest: 7.4.30

      End of life: 2010-10-01

    • Cycle 7.3

      Released: 2002-11-27

      Latest: 7.3.21

      End of life: 2007-11-27

    • Cycle 7.2

      Released: 2002-02-04

      Latest: 7.2.8

      End of life: 2007-02-04

    • Cycle 7.1

      Released: 2001-04-13

      Latest: 7.1.3

      End of life: 2006-04-13

    • Cycle 7.0

      Released: 2000-05-08

      Latest: 7.0.3

      End of life: 2005-05-08

    • Cycle 6.5

      Released: 1999-06-09

      Latest: 6.5.3

      End of life: 2004-06-09

    • Cycle 6.4

      Released: 1998-10-30

      Latest: 6.4.2

      End of life: 2003-10-30

    • Cycle 6.3

      Released: 1998-03-01

      Latest: 6.3.2

      End of life: 2003-03-01

    • Cycle 6.2

      Released: 1997-10-02

      Latest: 6.2.1

      End of life: true

    • Cycle 6.1

      Released: 1997-06-08

      Latest: 6.1.1

      End of life: true

    • Cycle 6.0

      Released: 1997-01-29

      Latest: 6.0

      End of life: true

    Project activity

    As of , collected daily. Status: snapshot.

    RepositoryGitHub InsightsOSS Insight

    Commit cadence (last 90 days)

    Commit cadence (last 90 days)

    • 2026-10-10: 9 commits
    • 2026-10-12: 4 commits
    • 2026-10-13: 6 commits
    • 2026-10-14: 23 commits
    • 2026-10-15: 16 commits
    • 2026-10-16: 14 commits
    • 2026-10-17: 3 commits
    • 2026-10-18: 2 commits
    • 2026-10-19: 9 commits
    • 2026-10-20: 7 commits
    • 2026-10-21: 12 commits
    • 2026-10-22: 13 commits
    • 2026-10-23: 3 commits
    • 2026-10-24: 3 commits
    • 2026-10-25: 7 commits
    • 2026-10-26: 13 commits
    • 2026-10-27: 11 commits
    • 2026-10-28: 5 commits
    • 2026-10-29: 15 commits
    • 2026-10-30: 14 commits
    • 2026-10-31: 3 commits
    • 2026-11-01: 8 commits
    • 2026-11-02: 15 commits
    • 2026-11-03: 13 commits
    • 2026-11-04: 14 commits
    • 2026-11-05: 13 commits
    • 2026-11-06: 22 commits
    • 2026-11-07: 1 commits
    • 2026-11-08: 1 commits
    • 2026-11-09: 88 commits
    • 2026-11-10: 7 commits
    • 2026-11-11: 20 commits
    • 2026-11-12: 18 commits
    • 2026-11-13: 7 commits
    • 2026-11-14: 1 commits
    • 2026-11-16: 3 commits
    • 2026-11-17: 2 commits
    • 2026-11-18: 24 commits
    • 2026-11-19: 21 commits
    • 2026-11-20: 18 commits
    • 2026-11-21: 4 commits

    Release timeline

    No data in this snapshot.

    Contributor spread (top 12 in snapshot)

    Contributor spread (top 12 in snapshot)

    • bmomjian: 14115 contributions
    • petere: 6630 contributions
    • tglsfdc: 5636 contributions
    • michaelpq: 2695 contributions
    • alvherre: 2240 contributions
    • hlinnaka: 1982 contributions
    • anarazel: 1573 contributions
    • scrappy: 1491 contributions
    • lockhart: 1078 contributions
    • adunstan: 1020 contributions

    Tags: REL_19_0, REL_19_RC2, REL_18_7, REL_17_12, REL_16_16, REL_15_20, REL_14_25, REL_19_RC1, REL_19_BETA4, REL_18_6, REL_19_BETA3, REL_17_11, REL_16_15, REL_15_19, REL_14_24, REL_19_BETA2, REL_19_BETA1, REL_18_4, REL_17_10, REL_16_14

    Pull requests: 0 opened, 0 closed in the snapshot window.

    Issues: 0 opened, 0 closed in the snapshot window.

    Course guides

    No public HOWTO titles are available yet.

    Learn PostgreSQL in the owner course →