Skip to content
Related Articles

Related Articles

PostgreSQL – Show Databases

View Discussion
Improve Article
Save Article
Like Article
  • 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+


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:


This will lead to the following:

Alternatively one can use the below command:



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;


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

SELECT datname FROM pg_database;


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!