Overview
You can call this API to query the SQL text of an OceanBase instance.
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}/details
Request parameters
Query
| Name | Type | Required | Description | Example value |
|---|---|---|---|---|
| instanceId | String | No | The ID of the OceanBase instance. | 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/annomalySQL. | 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/annomalySQL. | tf_**** |
| startTime | String | No | The start time. The time must be in UTC and in the format of: YYYY-MM-DDThh:mm:ssZ. | 2021-06-13T15:40:43Z |
| endTime | String | No | The end time. The time must be in UTC and in the format of: YYYY-MM-DDThh:mm:ssZ. | 2021-09-13T15:40:43Z |
| parameterized | Boolean | No | Indicates whether the SQL text is parameterized. | false |
Response parameters
| Name | Type | Description | Example value |
|---|---|---|---|
| data | json | The SQL text. | |
| 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, the fulltext field displays the full text. Otherwise, the content is the same as that in the statement field. | 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 a parameter contains special characters, you must escape them. For example, -d'@avgCpuTime>0' must be changed to -d'%40avgCpuTime%3E0'. The colon (:) in the time parameter is a special character and must be escaped.
- 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
}
