The createdb reference page contains the invocation details. It connects to the postgres database and issues the CREATE DATABASE command, exactly as described above. More details appear in Section 23.3.Īs a convenience, there is a program you can execute from the shell to create new databases, createdb.Ĭreatedb does no magic. It can be cloned instead of template1 when it is important to make a database without any such site-local additions. template0 is meant as a pristine copy of the original contents of template1. Because of this, avoid creating objects in template1 unless you want them propagated to every newly created database. This means that any changes you make in template1 are propagated to all subsequently created databases. Whenever a new database is created within the cluster, template1 is essentially cloned. Two additional databases, template1 and template0, are also created during database cluster initialization. So to create the first “ ordinary” database you can connect to postgres. (See Section 19.2.) This database is called postgres. The first database is always created by the initdb command when the data storage area is initialized. Since you need to be connected to the database server in order to execute the CREATE DATABASE command, the question remains how the first database at any given site can be created. See Section 22.2 for how to grant permission. The creation of databases is a restricted operation. It is the privilege of the owner of a database to remove it later (which also removes all the objects in it, even if they have a different owner). The current role automatically becomes the owner of the new database. Where name follows the usual rules for SQL identifiers. In order to create a database, the PostgreSQL server must be up and running (see Section 19.3).ĭatabases are created with the SQL command CREATE DATABASE:
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |