You can call this operation to create a database for a specified Apsara PolarDB cluster.

Before you call this operation, ensure that the following requirements are met:

  • The cluster is in the running state.
  • The cluster is not locked.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Name Type Required Example Description
Action String No CreateDatabase

The operation that you want to perform. Set the value to CreateDatabase.

CharacterSetName String Yes utf8

The character set. For more information, see Character set.

DBClusterId String Yes pc-xxxxxxxxxx

The ID of the cluster that you want to manage.

DBName String Yes testDB

The name of the database that you want to create.

  • The name must contain lowercase letters, digits, hyphens (-), and underscores (_).
  • The name must start with a lowercase letter and end with a letter or digit. The name must be 1 to 64 characters in length.
DBDescription String No DBDesc

The description of the database.

  • The value cannot start with http:// or https://.
  • The value must be 2 to 256 characters in length.
AccountName String No testacc

The name of the account that you can use to connect to the database. You can call the DescribeAccounts operation to query the information of the account.

Note You can only enter a standard account. By default, privileged accounts have all database privileges.
AccountPrivilege String No ReadWrite

The privileges of the database account on the database. Valid values:

  • ReadWrite: read and write privileges.
  • ReadOnly: read-only privilege.
  • DMLOnly: executes only data manipulation language (DML) statements.
  • DDLOnly: executes only data definition language (DDL) statements.

If you do not set this parameter, the default value is ReadWrite.

Note This parameter is valid only when the value of the AccountName parameter is specified.
Collate String No C

The language that specifies the collation of the new database.

Note The language must be compatible with the character set specified by CharacterSetName.
Ctype String No C

The language that specifies the character classification for the database.

Note
  • The language must be compatible with the character set specified by CharacterSetName.
  • The value must be the same as that of the Collate parameter.

Response parameters

Name Type Example Description
RequestId String 2FED790E-FB61-4721-8C1C-07C627FA5A19

The ID of the request.

Examples

Sample requests

http(s)://[Endpoint]/? Action=CreateDatabase
&CharacterSetName=utf8
&DBClusterId=pc-xxxxxxxxxx
&DBName=testDB
&<Common request parameters>

Sample success responses

XML format

<CreateDatabaseResponse>  
       <RequestId>2FED790E-FB61-4721-8C1C-07C627FA5A19</RequestId>
</CreateDatabaseResponse>

JSON format

{
   "RequestId": "2FED790E-FB61-4721-8C1C-07C627FA5A19"
}

Error codes

For a list of error codes, visit the API Error Center.