Now that the PostgreSQL database is running, you have the option of using the default database named template1. If you create a new database and you would like all of your consecutive databases to have the same system wide options, then you should first configure the template1 database to have those options enabled. For instance, if you plan to use the plpgsql language to program, then you should install the plpgsql language into template1 before using createdb. Then when you use the createdb command, the database created will inherit template1's options and thus, inherit the plpgsql language. For more information on installing the plpgsql language into the database, refer to the section on adding pl/pgSQL to your database.
PostgreSQL should now be up and running. The first step will be to create a new database. This will be our test database. We do not recommend using the default template1 database for testing purposes. As we have not created any users with database creation rights, you will want to make sure that you are logged in as postgres when adding a new database. You can create users that are allowed to add databases but that is discussed later on in the book. To create a new database you can enter a the following command at command line:
You should receive a message which says CREATE DATABASE. PostgreSQL provides an interface called psql. You can use psql to access the newly created database by entering the command:
You can now start entering SQL commands at the psql prompt. If you are unfamiliar with psql, please see the Basic Psql chapter.