You can call the CreateDatabase operation to create a database on an instance.

If you want to perform data management tasks such as data change and schema design, use Data Management (DMS). For more information, see List of operations by function of DMS.

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

  • The instance is in the Running state.
  • The maximum number of databases for the instance is not reached. You can call the DescribeDBInstanceAttribute operation to query the maximum number of databases.
  • The instance is not a read-only instance.
    Note This operation is not supported for instances that run SQL Server 2017 EE (cluster edition) or instances that run PostgreSQL and use local SSDs. If the instance runs one of these database engine versions, you can execute the CREATE DATABASE statement to create a database.

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

ParameterTypeRequiredExampleDescription
ActionStringYesCreateDatabase

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

DBInstanceIdStringYesrm-uf6wjk5xxxxxxxxxx

The ID of the instance.

DBNameStringYesrds_mysql

The name of the database.

Note
  • The name must be 2 to 64 characters in length.
  • The name must start with a lowercase letter and end with a lowercase letter or digit.
  • The name can contain lowercase letters, digits, underscores (_), and hyphens (-).
  • The name must be unique within the instance.
  • For more information about invalid characters, see Forbidden keywords table.
CharacterSetNameStringYesgbk

The character set.

  • Valid values for MySQL or MariaDB databases: utf8, gbk, latin1, and utf8mb4
  • Valid values for SQL Server databases: Chinese_PRC_CI_AS, Chinese_PRC_CS_AS, SQL_Latin1_General_CP1_CI_AS, SQL_Latin1_General_CP1_CS_AS, and Chinese_PRC_BIN
  • Valid values for PostgreSQL databases: a value in the Character set,<Collate>,<Ctype> format. Example: UTF8,C,en_US.utf8.
    • Valid values for the character set: KOI8U, UTF8, WIN866, WIN874, WIN1250, WIN1251, WIN1252, WIN1253, WIN1254, WIN1255, WIN1256, WIN1257, WIN1258, EUC_CN, EUC_KR, EUC_TW, EUC_JP, EUC_JIS_2004, KOI8R, MULE_INTERNAL, LATIN1, LATIN2, LATIN3, LATIN4, LATIN5, LATIN6, LATIN7, LATIN8, LATIN9, LATIN10, ISO_8859_5, ISO_8859_6, ISO_8859_7, ISO_8859_8, and SQL_ASCII
    • Valid values for the Collate field: You can execute the SELECT DISTINCT collname FROM pg_collation; statement to obtain the field value. The default value is C.
    • Valid values for the Ctype field: You can execute the SELECT DISTINCT collctype FROM pg_collation; statement to obtain the field value. The default value is en_US.utf8.
DBDescriptionStringNoTest database

The description of the database. The description must be 2 to 256 characters in length and can contain letters, digits, underscores (_), and hyphens (-). The description must start with a letter.

Note The description cannot start with http:// or https://.
ResourceGroupIdStringNorg-acfmy*****

The ID of the resource group.

Response parameters

ParameterTypeExampleDescription
RequestIdString5A77D650-27A1-4E08-AD9E-59008EDB6927

The ID of the request.

Examples

Sample requests

http(s)://rds.aliyuncs.com/?Action=CreateDatabase
&DBInstanceId=rm-uf6wjk5xxxxxxxxxx
&DBName=rds_mysql
&CharacterSetName=gbk
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<CreateDatabaseResponse>
  <RequestId>5A77D650-27A1-4E08-AD9E-59008EDB6927</RequestId>
</CreateDatabaseResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

{
  "RequestID" : "5A77D650-27A1-4E08-AD9E-59008EDB6927"
}

Error codes

HTTP status codeError codeError messageDescription
400EngineMigration.ActionDisabledSpecified action is disabled while custins is in engine migration.The error message returned because the specified operation is disabled during the engine migration for the instance.
400Database.AddErrorCreate Db failed, please check input value and instance statusThe error message returned because the database fails to be created. Check the input parameters and the instance status.
400Database.ConnectErrorDatabase connect error. please check instance status and database processlistThe error message returned because the database connection is abnormal. Check the instance status and the connection pool of the database.

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