Creating a Database
Function
This API is used to create a database in a specified DB instance. Before calling this API:
- Learn how to authenticate this API.
Constraints
This API can only be used to create a single database. This operation cannot be performed when the instance is in any of the following statuses: creating, changing instance specifications, or abnormal.
URI
POST https://{Endpoint}/v3/{project_id}/instances/{instance_id}/database
| Parameter | Mandatory | Description |
|---|---|---|
| project_id | Yes | Explanation: Project ID of a tenant in a region. To obtain the value, see Obtaining a Project ID. Restrictions: None Value range: The value can contain 32 characters. Only letters and digits are allowed. Default value: None |
| instance_id | Yes | Instance ID. |
Request Parameters
| Parameter | Mandatory | Type | Description |
|---|---|---|---|
| name | Yes | String | Database name. The value can contain 1 to 63 characters, including letters, digits, and underscores (_). It cannot start with pg or a digit, and must be different from template database names. Template databases include postgres, template0, template1, and templatem. |
| character_set | No | String | Character set. |
| owner | No | String | Database user. The default value is root. The value must be an existing username and must be different from system usernames. System users: rdsAdmin, rdsMetric, rdsBackup, and rdsRepl. |
| template | No | String | Name of the database template. The value can be template0. |
| lc_collate | No | String | Database collation. The default value is C. Comparison of the same string in different collations may have different results. For example, the execution result of select 'a'>'A'; is false when this parameter is set to en_US.utf8 and is true when this parameter is set to 'C'. If a database is migrated from Oracle to GaussDB, this parameter needs to be set to 'C' to meet your expectations. You can query the supported collations from the pg_collation table. |
| lc_ctype | No | String | Database classification. The default value is C. |
Response Parameters
None
Example Request
POST https://gaussdb-opengauss.eu-west-101.myhuaweicloud.eu/v3/0483b6b16e954cb88930a360d2c4e663/instances/{instance_id}/database
{
"name" : "gaussdb_test",
"owner" : "test",
"template" : "template0",
"character_set" : "UTF8",
"lc_collate" : "en_US.UTF-8",
"lc_ctype" : "en_US.UTF-8"
} Example Response
None
Status Code
- Normal
- Abnormal
For details, see Status Codes.
Error Codes
For details, see Error Codes.