List all databases on the server

Read-only
What do risk levels mean?
Read-only
Inspects state without changing anything.
Low risk
Reversible with a routine follow-up command.
Medium risk
Changes state; undo path documented.
Destructive
Deletes or overwrites; confirmation required.

Shows every database accessible to the current connection so you can confirm which databases exist before connecting or operating on one.

postgresqllistinspectcatalog

Commands

List all databases with owner, encoding, and access privileges

psql -c "\l"

Verification

psql -c "\l"

A table of database names with owner, encoding, and collation is printed.

Undo

Not undoable

This recipe only reads catalog metadata and changes nothing.

Pitfalls

  • Requires psql and access to a running PostgreSQL instance; set PGHOST and PGUSER if the defaults do not apply.
  • The listing may include template databases (template0, template1) that cannot be connected to.

Related