PostgreSQL - SHOW DATABASE
The SHOW DATABASE in PostgreSQL is used to display the list of all available database present in sql server. But in MySQL this command directly display the list of all databases.
To show the list of database, use the following commands or query −
Using SELECT Statement
The SELECT statement is one way to retrieve the list of all databases. All this data is present on the PostgreSQL server.
SELECT datname FROM pg_database;
The above query display the following result −
Using pSQL Command
The short form of PostgreSQL is pSQL, which provides two useful commands to generate the list of all databases.
Syntax
Following are the two pSQL command to collect the list of all databases.
\l
Or,
\l+
To run the pSQL shell, first log into the postgreSQL server.
Now use the above syntaxes one by one and check all the listed databases.
Below are the screenshots of all databases using the pSQL command −