Creates a database for a PolarDB cluster.
Before you call this operation, make sure that the following requirements are met:
- The cluster is in the Running state.
- The cluster is unlocked.
Debugging
Request parameters
Parameter | Type | Required | Example | Description |
---|---|---|---|---|
Action | String | Yes | CreateDatabase | The operation that you want to perform. Set the value to CreateDatabase. |
DBClusterId | String | Yes | pc-************** | The ID of the cluster. |
DBName | String | Yes | testDB | The name of the database. The name must meet the following requirements:
Note The name cannot be a keyword that is reserved by the system, such as test or mysql . |
CharacterSetName | String | Yes | utf8 | The character set that is used by the cluster. For more information, see Character set tables. |
DBDescription | String | No | testdesc | The description of the database. The description must meet the following requirements:
Note This parameter is required if your cluster is a PolarDB for PostgreSQL(Compatible with Oracle) cluster or a PolarDB for PostgreSQL cluster. This parameter is not required if your cluster is a PolarDB for MySQL cluster. |
AccountName | String | No | testacc | The name of the account that is granted permissions to access the database. You can call the DescribeAccounts operation to query account information. Note
|
AccountPrivilege | String | No | ReadWrite | The permissions that are granted to the account. Valid values:
If you leave this parameter empty, the default value ReadWrite is used. Note
|
Collate | String | No | C | The language that specifies the collation of the database that is to be created. Note
|
Ctype | String | No | C | The language that specifies the character type of the database. Note
|
Response parameters
Parameter | Type | Example | Description |
---|---|---|---|
RequestId | String | 93E98F25-BE02-40DA-83E3-F77F8D****** | The ID of the request. |
Examples
Sample requests
http(s)://polardb.aliyuncs.com/?Action=CreateDatabase
&DBClusterId=pc-**************
&DBName=testDB
&CharacterSetName=utf8
&DBDescription=testdesc
&AccountName=testacc
&AccountPrivilege=ReadWrite
&Collate=C
&Ctype=C
&<Common request parameters>
Sample success responses
XML
format
HTTP/1.1 200 OK
Content-Type:application/xml
<CreateDatabaseResponse>
<RequestId>93E98F25-BE02-40DA-83E3-F77F8D******</RequestId>
</CreateDatabaseResponse>
JSON
format
HTTP/1.1 200 OK
Content-Type:application/json
{
"RequestId" : "93E98F25-BE02-40DA-83E3-F77F8D******"
}
Error codes
HTTP status code | Error code | Error message | Description |
---|---|---|---|
400 | InvalidDBName.Malformed | The specified parameter DBName is not valid. | The error message returned because the format of the specified database name is invalid. |
400 | Database.AddError | Instance %s add database minidoc error | The error message returned because the database minidoc failed to be added to cluster %s. |
404 | InvalidDBCluster.NotFound | The DBClusterId provided does not exist in our records. | The error message returned because the specified cluster ID does not exist in the current record. |
For a list of error codes, see Service error codes.