Creates a new database.
CREATE DATABASE name [ [WITH] [OWNER [=] <dbowner>] [TEMPLATE [=] <template>] [ENCODING [=] <encoding>] [TABLESPACE [=] <tablespace>] [CONNECTION LIMIT [=] connlimit ] ]
CREATE DATABASE creates a new database. To create a database, you must be a superuser or have the special
The creator becomes the owner of the new database by default. Superusers can create databases owned by other users by using the
OWNER clause. They can even create databases owned by users with no special privileges. Non-superusers with
CREATEDB privilege can only create databases owned by themselves.
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 clean database containing only the standard objects predefined by Greenplum Database. This is useful if you wish to avoid copying any installation-local objects that may have been added to
DEFAULTto use the default owner (the user executing the command).
DEFAULTto use the default template (template1).
'SQL_ASCII'), an integer encoding number, or
DEFAULTto use the default encoding. For more information, see Character Set Support.
DEFAULTto use the template database's tablespace. This tablespace will be the default tablespace used for objects created in this database.
CREATE DATABASE cannot be executed inside a transaction block.
When you copy a database by specifying its name as the template, no other sessions can be connected to the template database while it is being copied. New connections to the template database are locked out until
CREATE DATABASE completes.
CONNECTION LIMIT is not enforced against superusers.
To create a new database:
CREATE DATABASE gpdb;
To create a database
sales owned by user
salesapp with a default tablespace of
CREATE DATABASE sales OWNER salesapp TABLESPACE salesspace;
To create a database
music which supports the ISO-8859-1 character set:
CREATE DATABASE music ENCODING 'LATIN1';
There is no
CREATE DATABASE statement in the SQL standard. Databases are equivalent to catalogs, whose creation is implementation-defined.
Parent topic: SQL Command Reference