PostgreSQL - Show Databases - GeeksforGeeks

PostgreSQL - Show Databases

Last Updated : 15 Oct, 2026

PostgreSQL does not support the SHOW DATABASES command. Instead, you can list databases in PostgreSQL using the \l or \l+ meta-commands in the psql terminal or by querying the pg_database system catalog.

  • Use \l or \l+ to display databases through the psql terminal.
  • Query pg_database to retrieve database names using SQL.
  • These methods help you view databases available on the PostgreSQL server.

Method 1: Using the psql Command

To list all databases present on the current PostgreSQL server, use one of the following psql meta-commands.

\l

or

\l+

Now use the below command to list all databases using a superuser such as postgres:

\l

Output:

Alternatively one can use the below command:

\l+

Output:

Method 2: Using the SELECT Statement

To list all databases by querying the pg_database system catalog using the SELECT statement.

Syntax:

SELECT column_name
FROM pg_database;

Example:

Execute the following query to retrieve the names of all databases available on the PostgreSQL server:

SELECT datname 
FROM pg_database;

Note: datname is the column in pg_database that stores database names.

Output:

Screenshot-2026-09-29-122728
Comment

Explore