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.
- Obtain the required region and endpoint.
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, frozen, 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. For details about how to obtain the project ID, 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. The default value is UTF8. |
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.
NOTICE:
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 "O" 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.ap-southeast-1.myhuaweicloud.com/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 Code
For details, see Error Codes.
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot