Updated on 2022-12-07 GMT+08:00

Creating a Schema

Function

This API is used to create a schema.

Constraints

Before creating a schema, ensure that you have imported available RDS DB instances into the required DDM instance and that the RDS DB instances are not associated with other DDM instances.

URI

POST /v1/{project_id}/instances/{instance_id}/databases

Table 1 Path parameters

Parameter

Mandatory

Type

Description

project_id

Yes

String

Project ID of a tenant in a region

instance_id

Yes

String

DDM instance ID

Request Parameters

Table 2 Request header parameters

Parameter

Mandatory

Type

Description

X-Auth-Token

Yes

String

User token

It can be obtained by calling the IAM API (value of X-Subject-Token in the response header).

Table 3 Request body parameters

Parameter

Mandatory

Type

Description

databases

Yes

Array of CreateDDMDatabaseDetail objects

Schema information

Table 4 Parameters for creating a schema

Parameter

Mandatory

Type

Description

name

Yes

String

Schema name, which:

  • Consists of 2 to 24 characters.
  • Starts with a lowercase letter.
  • Contains only lowercase letters, digits, and underscores (_).
  • The schema name cannot contain keywords information_schema, mysql, performance_schema, or sys.

Minimum length: 2

Maximum length: 24

shard_mode

Yes

String

Sharding mode of the schema. The value can be:

  • cluster: indicates that the schema is in sharded mode.
  • single: indicates that the schema is in unsharded mode.

Possible values are as follows:

  • cluster
  • single

shard_number

Yes

Integer

Number of shards in the same working mode. The value is the product of the shard_unit value and the number of associated RDS DB instances.

shard_unit

Yes

Integer

Number of shards per RDS DB instance

  • For unsharded schemas, the value is fixed at 1.
  • For sharded schemas, the default value is 8. You can change the value to 16 or 32.

Possible values are as follows:

  • 8
  • 16
  • 32

used_rds

Yes

Array of DDMDatabaseInstabcesParam objects

RDS DB instance to be associated with the schema

Table 5 Schema parameters

Parameter

Mandatory

Type

Description

id

Yes

String

ID of the RDS DB instance associated with the schema

adminUser

Yes

String

Username for logging in to the associated RDS DB instance

adminPassword

Yes

String

Password for logging in to the associated RDS DB instance

Response Parameters

Status code: 200

Table 6 Response body parameters

Parameter

Type

Description

databases

Array of CreateDDMDatabaseDetaillResponses objects

Schema information

Table 7 Parameters for creating a schema

Parameter

Type

Description

name

String

Schema name

Status code: 400

Table 8 Response body parameters

Parameter

Type

Description

errCode

String

Service error code

externalMessage

String

Error message

Status code: 500

Table 9 Response body parameters

Parameter

Type

Description

errCode

String

Service error code

externalMessage

String

Error message

Example Request

The following is an example request of creating a schema and associating it with an existing DDM account.

POST https://{endpoint}/v1/{project_id}/instances/{instance_id}/databases

{
  "databases" : [ {
    "name" : "mytestdb",
    "shard_mode" : "cluster",
    "shard_number" : 8,
    "shard_unit" : 8,
    "used_rds" : [ {
      "id" : "f296c394f13f48449d715bf99af07e59in01",
      "adminUser" : "root",
      "adminPassword" : "PassWord_234"
    } ]
  } ]
}

Example Response

Status code: 200

OK

{
  "databases" : [ {
    "name" : "mytestdb"
  } ]
}

Status code: 400

bad request

{
  "externalMessage" : "Parameter error.",
  "errCode" : "DBS.280001"
}

Status code: 500

server error

{
  "externalMessage" : "Parameter error.",
  "errCode" : "DBS.280001"
}

Status Codes

For details, see Status Codes.

Error Codes

For details, see Error Codes.