Overview
You can call this API to query the list of original SQL texts of the specified SQL ID within the specified time period. This API can be used to analyze the execution pattern of a specific SQL statement or perform SQL auditing.
API details
Constraints
The caller must have an AccessKey for accessing multi-cloud APIs. For information about how to obtain the AccessKey ID and AccessKey secret, see Manage AccessKeys.
Request path
GET /api/v2/instances/{instanceId}/tenants/{tenantId}/sqls/{sqlId}/sampleSql
Request parameters
Path
| Name | Type | Required | Description | Example value |
|---|---|---|---|---|
| instanceId | String | Yes | The ID of the OceanBase cluster. | obcluster-***** |
| tenantId | String | Yes | The ID of the tenant. | t4louaeei**** |
| sqlId | String | Yes | The unique identifier of the SQL statement. | sql_123456789 |
Query
| Name | Type | Required | Description | Example value |
|---|---|---|---|---|
| requestId | String | Yes | The ID of the request, which is used for tracing. | dc302d76-66b5-48d8-ab53-a035******** |
| dbName | String | Yes | The name of the database. | testdb |
| startTime | String | Yes | The start time in UTC. | 2026-02-25 15:40:43+00:00 |
| endTime | String | Yes | The end time in UTC. | 2026-02-26 10:40:43+00:00 |
| dynamicSql | Boolean | No | The dynamic sql parameter. | false |
| limit | Integer | Yes | The maximum number of results to return. | 10 |
Response parameters
| Parameter | Type | Description |
|---|---|---|
| data | Object | The original SQL text data. |
| data.dataList | Array<Object> |
The list of SQL texts. |
| data.dataList[].sqlText | Array |
The array of SQL texts. |
| data.total | Integer | The total number of items. |
| requestId | String | The ID of the request. |
| success | Boolean | Indicates whether the request was successful. |
Examples
Request example
curl --digest -u '<your ak:sk>' \
-X GET \
'https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/tenants/{tenantId}/sqls/{sqlId}/sampleSql?requestId={requestId}&dbName={dbName}&startTime={startTime}&endTime={endTime}&limit={limit}' \
-G
Response example
JSON format
{
"data": {
"dataList": [
{
"sqlText": [
"SELECT * FROM in_table_0915 WHERE id IN ('1')"
]
}
],
"total": 1
},
"requestId": "136f85a2-5fac-4a0d-adf7-8735511ba28c",
"success": true
}
