Overview
You can call this API to query the SQL text information.
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
GET /api/v2/instances/{instanceId}/tenants/{tenantId}/sqls/{sqlId}/details
Request parameters
Query
| Name | Type | Required | Description | Example value |
|---|---|---|---|---|
| instanceId | String | No | The ID of the OceanBase cluster. | ob317v4uif**** |
| tenantId | String | No | The ID of the tenant. | t33h8y08k**** |
| sqlId | String | No | The ID of the SQL statement. You can obtain this ID from topSQL, slowSQL, or anomalySQL. | 6E05****E4D418C927918CDB62A0**** |
Body
| Name | Type | Required | Description | Example value |
|---|---|---|---|---|
| dbName | String | No | The name of the database. You can obtain this name from topSQL, slowSQL, or anomalySQL. | tf_**** |
| startTime | String | No | The start time. This parameter only supports UTC time in the format of: YYYY-MM-DDThh:mm:ssZ. | 2021-06-13T15:40:43Z |
| endTime | String | No | The end time. This parameter only supports UTC time in the format of: YYYY-MM-DDThh:mm:ssZ. | 2021-09-13T15:40:43Z |
| parameterized | Boolean | No | Specifies whether the SQL text is parameterized. | false |
Response parameters
| Name | Type | Description | Example value |
|---|---|---|---|
| data | json | The SQL text information. | |
| dbName | String | The name of the database. | tf_**** |
| fulltext | string | The SQL text. Note: The value of the parameterized parameter affects the fulltext. If parameterized is false, fulltext displays the entire text. Otherwise, fulltext is the same as statement. | select sum(id), substring (name, 10, 21), sleep(?) from table_scan_index_not_used where name not like ?; |
| sqlId | string | The ID of the SQL statement. | 6E05****E4D418C927918CDB62A0**** |
| statement | string | The parameterized SQL text. | select sum(id), substring (name, 10, 21), sleep(?) from table_scan_index_not_used where name not like ?; |
| tables | array | The names of the tables parsed from the SQL text. | ["table_scan_index_not_used"] |
| userName | String | The username. | oas |
Examples
Request example
curl --digest -u 'ak:sk' \
--request GET \
--url https://api-cloud.oceanbase.com/api/v2/instances/{instanceId}/tenants/{tenantId}/sqls/{sqlId}/details
-H 'X-Ob-Project-Id: <Project ID>'
-G -d 'dbName=xx' -d 'startTime=xx' -d 'endTime=xxx' -d 'parameterized=false'
Note
- If the parameters contain special characters, escape them. For example, -d'@avgCpuTime>0' should be rewritten as -d'%40avgCpuTime%3E0'. The special characters in the time parameters, such as colon (:), must be escaped in time parameters.
- 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":{
"dbName":"tf_****",
"fulltext":"select sum(id), substring (name, 10, 21), sleep(?) from table_scan_index_not_used where name not like ?;",
"sqlId":"6E05****E4D418C927918CDB62A0****",
"statement":"select sum(id), substring (name, 10, 21), sleep(?) from table_scan_index_not_used where name not like ?;",
"tables":[
"table_scan_index_not_used"
],
"userName":"oas"
},
"requestId":"d2a322bf-****-4945-b92c-0bbf24d4****",
"success":true
}