PostgreSQL|How to List Databases in psql (\l Command)
This note explains how to display a list of databases when using PostgreSQL from the command line.
Logging in to psql
Log in with the following command:
psql -U postgres
Displaying the list of databases
Use the \l command:
\l
※ On Windows, it appears as "¥l" (half-width yen symbol).
※ On Linux, the "¥" is displayed as a backslash.
postgres=# \l
※ The character after the backslash is the lowercase letter l (as in "letter L"), not the number 1.
List of databases
Name | Owner | Encoding
----------------------+----------+----------
neko1_db | postgres | EUC_JP
neko2_db | postgres | EUC_JP
neko3_db | postgres | EUC_JP
postgres | postgres | EUC_JP
template0 | postgres | EUC_JP
template1 | postgres | EUC_JP
(6 rows)
Information shown in the list
In addition to the database names, you can also check the Owner and Encoding for each database.