PostgreSQL – Show Databases
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;
Whether you're preparing for your first job interview or aiming to upskill in this ever-evolving tech landscape, GeeksforGeeks Courses
are your key to success. We provide top-quality content at affordable prices, all geared towards accelerating your growth in a time-bound manner. Join the millions we've already empowered, and we're here to do the same for you. Don't miss out - check it out now!