You can execute the CREATE DATABASE statement to create a database. This topic describes how to use the CREATE DATABASE statement.
Limits
You can create up to 64 databases for a single instance.
Syntax
CREATE DATABASE db_name
[ [ WITH ] [ OWNER [=] user_name ]
;
The following table describes the parameters in the syntax.
Parameter | Description |
db_name | The name of the database that you want to create. Only letters, digits, and underscores (_) are supported. |
user_name | The name of the user that is authorized as the database owner. The account that is 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 superuser permissions to other users. The owner has the permission to delete the database. Note that when you delete the database, all objects in the database, including tables and data, are deleted. |
After you purchase a Hologres instance, a database named postgres is automatically created. This database is allocated with a few resources and used only for management purposes. Therefore, we recommend that you create another database to process business data.
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 this example, a database named testdb is created:
CREATE DATABASE testdb;