There's more...

The information that we just saw is stored in a PostgreSQL catalog table named pg_database. We can look at this directly to get some more information. In some ways, the output is less useful as well, as we need to look up some of the code in other tables:

postgres=# \x
postgres=# select * from pg_database;
-[ RECORD 1 ]-+------------------------------
datname | template1
datdba | 10
encoding | 6
datcollate | en_GB.UTF-8
datctype | en_GB.UTF-8
datistemplate | t
datallowconn | t
datconnlimit | -1
datlastsysoid | 11620
datfrozenxid | 644
dattablespace | 1663
datacl | {=c/sriggs,sriggs=CTc/sriggs}
-[ RECORD 2 ]-+------------------------------
datname | template0
datdba | 10
encoding | 6
datcollate | en_GB.UTF-8
datctype | en_GB.UTF-8
datistemplate | t
datallowconn | f
datconnlimit | -1
datlastsysoid | 11620
datfrozenxid | 644
dattablespace | 1663
datacl | {=c/sriggs,sriggs=CTc/sriggs}
-[ RECORD 3 ]-+------------------------------
datname | postgres
datdba | 10
encoding | 6
datcollate | en_GB.UTF-8
datctype | en_GB.UTF-8
datistemplate | f
datallowconn | t
datconnlimit | -1
datlastsysoid | 11620
datfrozenxid | 644
dattablespace | 1663
datacl |

First of all, look at the use of the \x command. It makes the output in psql appear as one column per line, rather than one row per line.

This output raises many questions, I know. We've already discussed templates. The other interesting things are that we can turn connections on and off for a database, and we can set connection limits for them as well.

Also, you can see that each database has a default tablespace. Therefore, data tables get created inside one specific database, and the data files for that table get placed in one tablespace.

You can also see that each database has a collation sequence, which is the way various language features are defined. We'll cover more on that in the Choosing good names for database objects recipe in Chapter 5, Tables and Data.