If you have access to psql, you can type the following command:
bash $ psql -l
List of databases
Name | Owner | Encoding | Collate | Ctype | Access privileges
-----------+--------+----------+-------------+-------------+-------------------
postgres | sriggs | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 |
template0 | sriggs | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/sriggs +
| | | | | sriggs=CTc/sriggs
template1 | sriggs | UTF8 | en_GB.UTF-8 | en_GB.UTF-8 | =c/sriggs +
| | | | | sriggs=CTc/sriggs
(3 rows)
You can also get the same information while running psql by simply typing \l.
The information that we just looked at is stored in a PostgreSQL catalog table named pg_database. We can issue a SQL query directly against that table from any connection to get a simpler result, as follows:
postgres=# select datname from pg_database;
datname
-----------
template1
template0
postgres
(3 rows)