SQL 参考
CREATE DATABASE

CREATE DATABASE

CREATE DATABASE — create a new database

Synopsis

CREATE DATABASE name

Description

CREATE DATABASE creates a new ProtonBase database.

To create a database, you must be a superuser or have the special CREATEDB privilege.

By default, the new database will be created by cloning the standard system database template1. A different template can be specified by writing TEMPLATE `name`. In particular, by writing TEMPLATE template0, you can create a pristine database (one where no user-defined objects exist and where the system objects have not been altered) containing only the standard objects predefined by your version of ProtonBase. This is useful if you wish to avoid copying any installation-local objects that might have been added to template1.

Parameters

name

The name of a database to create.

Optional parameters can be written in any order, not only the order illustrated above.

Notes

CREATE DATABASE cannot be executed inside a transaction block.

Errors along the line of “could not initialize database directory” are most likely related to insufficient permissions on the data directory, a full disk, or other file system problems.

Use DROP DATABASE to remove a database.

The program "app-createdb" is a wrapper program around this command, provided for convenience.

Examples

To create a new database:

CREATE DATABASE lusiadas;

Compatibility

There is no CREATE DATABASE statement in the SQL standard. Databases are equivalent to catalogs, whose creation is implementation-defined.