Wednesday, November 19, 2025

Tip of the Day - Oracle & PostgreSQL (Mon, 16 Mar 2026)

PostgreSQL DB - List all Databases


To list out all the existing databases in PostgreSQL:

1. Execute the SQL query from the system Catalog.

   SELECT datname FROM pg_database;

2. The psql program's \l meta-command and -l command-line option are also useful for listing the existing databases.

  • \l or \list - Lists all databases, their owners, and character encodings in the psql interface.
  • \l+ or \list+ - Provides more detailed information, including database size and default tablespace.
  • -l command-line option are also useful for listing the existing databases. (Ex: $ psql -l )

3. \c or \conninfo - displays the currently connected database.