You can execute the CREATE DATABASE statement to create a database. This topic describes how to use the CREATE DATABASE statement.


    [ [ WITH ] [ OWNER [=] user_name ]
The following table describes the parameters in the statement.
Parameter Description
db_name The name of the database to create. The value follows the usual rules for SQL identifiers.
user_name The name of the user to own the new database.

The account used to execute the statement is automatically specified as the owner of the database and has the permissions of a superuser. This account can be used to grant the owner privilege to other users.

The owner is authorized to delete the database. Note that when you delete the database, all objects in the database, including tables and data, are deleted.

Note After you purchase a Hologres instance, a database named postgres is created by default. This database is allocated with a few resources and only used for management purposes. We recommend that you create a database based on your business needs.

A superuser can create a database for another user and make the user the owner of the new database. This way, the owner is authorized to manage and configure the database.


In the following example, a database named testdb is created: