Applicability
Creating a database in a standby cluster is not supported in the current version.
Overview
You can call this API to create a database in a specified tenant.
API details
Constraints
The caller must have an AccessKey for accessing the multi-cloud API. For information about how to obtain the AccessKey ID and AccessKey secret, see Manage AccessKeys.
Request path
POST /api/v2/instances/{instanceId}/tenants/{tenantId}/databases
Request parameters
Query
| Name | Type | Required | Description | Example value |
|---|---|---|---|---|
| instanceId | string | Yes | The ID of the OceanBase cluster. | ob317v4uif**** |
| tenantId | string | Yes | The ID of the tenant. | ob2mr3oae0**** |
Body
| Name | Type | Required | Description | Example value |
|---|---|---|---|---|
| instanceId | string | Yes | The ID of the OceanBase cluster. | ob317v4uif**** |
| tenantId | string | Yes | The ID of the tenant. | ob2mr3oae0**** |
| databaseName | string | Yes | The name of the database. You cannot use reserved keywords such as test and mysql. | databasetest |
| encoding | string | Yes | The encoding method of the database. Currently, utf8mb4 and gbk are supported. | utf8mb4 |
| collation | string | No | The collation of the database. | utf8mb4_general_ci |
| description | string | No | The description of the database. | this is a test database |
| requestId | string | No | The request ID for idempotence control. | req-20231012094530-001 |
Response parameters
| Name | Type | Description |
|---|---|---|
| data | object | The information about the database. |
| success | boolean | Indicates whether the request was successful. |
Examples
Request example
curl -v --request POST \
--digest -u '<Your ak:sk>' \
--url 'https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/tenants/{tenantId}/databases' \
-H 'Content-Type: application/json' \
-H 'X-Ob-Project-Id: <Project ID>' \
--data '{"instanceId":"ob4ioyiw82yhuo","tenantId":"t4ismze9nltds","databaseName":"databasetest","encoding":"utf8mb4","collation":"utf8mb4_general_ci","description":"this is a test database","requestId":"req-20231012094530-001"}'
Note
- A project ID uniquely identifies a project. For information about how to obtain the project ID of an instance, see Manage projects.
- Make sure that the project ID corresponding to the specified instanceId is consistent with the specified project ID.
Response example
JSON format
{
"data": {},
"success": true
}
