Creating a Schema

Function

This API is used to create a schema.

URI

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

Table 1 Parameter description

Parameter

Mandatory

Description

project_id

Yes

Project ID of a tenant in a region

instance_id

Yes

DDM instance ID

Request

Request parameters

Table 2 Parameter description

Parameter

Mandatory

Type

Description

databases

Yes

Array

Schema information. For details about the parameters, see Table 3.

Table 3 Description of parameter databases

Parameter

Mandatory

Type

Description

name

Yes

String

Schema name, which:

  • Consists of 2 to 24 characters.
  • Must start with a letter and is case-insensitive.
  • Contains only letters, digits, and underscores (_).
  • Cannot be the following names:

    information_schema, mysql, performance_schema, or sys

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.

shard_number

Yes

Integer

Number of shards in the same sharding 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 8 or 16 to suit your needs.

used_rds

Yes

Array

RDS DB instance to be associated with the schema

Table 4 Description of parameter used_rds

Parameter

Mandatory

Type

Description

id

Yes

String

ID of the RDS DB instance associated with the schema

adminUser

Yes

String

Owner of the associated RDS DB instance

adminPassword

Yes

String

Password for logging in to the associated RDS instance

Response

Response parameters

Table 5 Parameter description

Parameter

Type

Mandatory

Description

databases

Array

true

Schema information

Table 6 Description of parameter databases

Parameter

Type

Description

name

String

Schema name

Example

  • Example request
    {
      "databases": [
        {
          "name": "ljj_833211",
          "shard_mode": "cluster",
          "shard_number": 8,
          "shard_unit": 8,
          "used_rds": [
            {
              "id": "f296c394f13f48449d715bf99af07e59in01",
              "adminUser": "root",
              "adminPassword": "Gauss_234"
            }
          ]
        }
      ]
    }
    
  • Example response
    {
        "databases": [
            {
                "name": "test123"
            }
        ]
    }

For failure responses, see Abnormal Request Results.

Status Code

For details, see Status Codes.