Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

PostgreSQL – Show Databases

  • Last Updated : 28 Aug, 2020

In PostgreSQL,  there are couple of ways to list all the databases present on the server. In this article, we will explore them.

Using the pSQL command:

To list all the database present in the current database server use one of the following commands:

Syntax: \l or \l+

Example:

First log into the PostgreSQL server using the pSQL shell:



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

\l

This will lead to the following:

Alternatively one can use the below command:

\l+

Output:

Using SELECT statement:

The SELECT statement can also be used to list all the database present on the server:

Syntax: SELECT datname FROM pg_database;

Example:

Below is the simple use of the SELECT statement to list all database present on the server:

SELECT datname FROM pg_database;

Output:

My Personal Notes arrow_drop_up
Recommended Articles
Page :