You can execute the CREATE DATABASE statement to create a database. This topic describes how to use the CREATE DATABASE statement.
Syntax
CREATE DATABASE db_name
[ [ 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. |
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.
Examples
In the following example, a database named testdb is created:
CREATE DATABASE testdb;