CreateDatabase

2025-11-26 03:33:16  Updated

Applicability

Creating a database in a standby instance is not supported in the current version.

Overview

You can call this API to create a database in a tenant.

API details

Constraints

The caller must have an AccessKey for accessing APIs of OceanBase Cloud. For information about how to obtain the AccessKey ID and AccessKey secret, see Manage AccessKeys.

Request path

GET /api/v2/instances/{instanceId}/tenants/{tenantId}/databases

Request parameters

Query

Parameter 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 format of the database. At present, the utf8mb4 and gbk encoding formats are supported. utf8mb4
description String No The description of the database. This is a test database

Body

Parameter 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 format of the database. At present, the utf8mb4 and gbk encoding formats are supported. utf8mb4
description String No The description of the database. This is a test database

Response parameters

Parameter Type Description Example value
data Object The information about the database.
databaseName String The name of the database. You cannot use reserved keywords, such as test and mysql. databasetest

Examples

Request example

curl -v  --request POST \
  --digest   -u 'ak:sk' \
  --url 'https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/tenants/{tenantId}/databases' \
  -H 'X-Ob-Project-Id: <Project ID>'
  --data '{"instanceId":"ob4ioyiw82yhuo","tenantId":"t4ismze9nltds","databaseName":"test","encoding":"utf8mb4","description":"testtt"}'

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":{
		"databaseName":"databasetest"
	},
	"success":true
}

Contact Us