Overview
You can call this API to query the schema of a specified table in a specified tenant of a specified OceanBase Cloud instance. You can specify the table name, database name, and time range to obtain the detailed schema definition.
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}/schema
Request parameters
Path parameters
| Parameter |
Type |
Required |
Description |
Example value |
| instanceId |
string |
Yes |
The ID of the OceanBase Cloud instance. |
obcluster-***** |
| tenantId |
string |
Yes |
The ID of the tenant. |
t4louaeei**** |
Query parameters
| Parameter |
Type |
Required |
Description |
Example value |
| requestId |
string |
Yes |
The request ID. |
dc302d76-66b5-48d8-ab53-a035******** |
Request body parameters
| Parameter |
Type |
Required |
Description |
Example value |
| startTime |
string |
No |
The start time of the query. |
2023-10-01 00:00:00 |
| endTime |
string |
No |
The end time of the query. |
2023-10-31 23:59:59 |
| sqlType |
string |
No |
The SQL type. |
SELECT |
| sqlId |
string |
No |
The SQL ID. |
8D6E84B0E0A7976E |
| requestId |
string |
No |
The request ID. |
dc302d76-66b5-48d8-ab53-a035******** |
| instanceId |
string |
No |
The ID of the OceanBase Cloud instance. |
obcluster-***** |
| tenantId |
string |
No |
The ID of the tenant. |
t4louaeei**** |
| dbName |
string |
No |
The name of the database. |
test_db |
| tableNames |
array[string] |
No |
The list of table names for which you want to query the schema. |
["table1", "table2"] |
Response parameters
| Parameter |
Type |
Description |
| code |
string |
The return code. |
| data |
object |
The returned data. |
| message |
string |
The return message. |
| requestId |
string |
The request ID. |
| server |
string |
The server address. |
| success |
boolean |
Indicates whether the request was successful. |
Examples
Request example
curl -X POST \
-H "Content-Type: application/json" \
-u '<your ak:sk>' \
"https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/tenants/{tenantId}/schema?requestId={requestId}" \
-d '{
"startTime": "2023-10-01 00:00:00",
"endTime": "2023-10-31 23:59:59",
"sqlType": "SELECT",
"sqlId": "8D6E84B0E0A7976E",
"requestId": "{requestId}",
"instanceId": "{instanceId}",
"tenantId": "{tenantId}",
"dbName": "test_db",
"tableNames": ["table1", "table2"]
}'
Response example
{
"code": "200",
"data": {
"tableSchemaList": [
{
"tableName": "table1",
"columns": [
{
"columnName": "id",
"dataType": "int",
"isNullable": "NO",
"columnDefault": null,
"extra": "auto_increment"
},
{
"columnName": "name",
"dataType": "varchar(255)",
"isNullable": "YES",
"columnDefault": null,
"extra": ""
}
]
}
]
},
"message": "success",
"requestId": "xxxxxx",
"server": "xxx.xxx.x.xxx:xxxx",
"success": true
}