How it works...

PostgreSQL starts with three databases: template0, template1, and postgres. The main user database is postgres.

You can create your own databases as well, like this:

CREATE DATABASE my_database;

You can do the same from the command line, using the following expression:

bash $ createdb my_database

After you've created your databases, make sure to secure them properly, as discussed in Chapter 6, Security.

When you create another database, it actually takes a copy of an existing database. Once it is created, there is no further link between the two databases.

The template0 and template1 databases are known as template databases. The template1 database can be changed to allow you to create a localized template for any new databases that you create. The template0 database exists so that, when you alter template1, you still have a pristine copy on which to fall back on. In other words, if you break template1, then you can drop it and recreate it from template0.

You can drop the database named postgres. But don't, okay? Similarly, don't try to touch template0, because you won't be allowed to do anything with it, except use it as a template. On the other hand, the template1 database exists to be modified, so feel free to change it.