- To list databses on psql terminal ( \l ) or ( \l + ) for detailed information
postgres=# \l List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges -----------+----------+----------+--------------------+--------------------+----------------------- postgres | postgres | UTF8 | English_India.1252 | English_India.1252 | template0 | postgres | UTF8 | English_India.1252 | English_India.1252 | =c/postgres + | | | | | postgres=CTc/postgres template1 | postgres | UTF8 | English_India.1252 | English_India.1252 | =c/postgres + | | | | | postgres=CTc/postgres (3 rows) postgres=# \l+ List of databases Name | Owner | Encoding | Collate | Ctype | Access privileges | Size | Tablespace | Description -----------+----------+----------+--------------------+--------------------+-----------------------+---------+------------+-------------------------------------------- postgres | postgres | UTF8 | English_India.1252 | English_India.1252 | | 7055 kB | pg_default | default administrative connection database template0 | postgres | UTF8 | English_India.1252 | English_India.1252 | =c/postgres +| 6945 kB | pg_default | unmodifiable empty database | | | | | postgres=CTc/postgres | | | template1 | postgres | UTF8 | English_India.1252 | English_India.1252 | =c/postgres +| 6945 kB | pg_default | default template for new databases | | | | | postgres=CTc/postgres | | | (3 rows)
2. List Databases from query (select * from pg_database);
postgres=# select * from pg_database;
datname | datdba | encoding | datcollate | datctype | datistemplate | datallowconn | datconnlimit | datlastsysoid | datfrozenxid | datminmxid | dattablespace | datacl
-----------+--------+----------+--------------------+--------------------+---------------+--------------+--------------+---------------+--------------+------------+---------------+-------------------------------------
postgres | 10 | 6 | English_India.1252 | English_India.1252 | f | t | -1 | 12400 | 536 | 1 | 1663 |
template1 | 10 | 6 | English_India.1252 | English_India.1252 | t | t | -1 | 12400 | 536 | 1 | 1663 | {=c/postgres,postgres=CTc/postgres}
template0 | 10 | 6 | English_India.1252 | English_India.1252 | t | f | -1 | 12400 | 536 | 1 | 1663 | {=c/postgres,postgres=CTc/postgres}
(3 rows)