Overview
You can call this API to query the text of an SQL statement in OceanBase Cloud.
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}/sqls/{sqlId}/text
Request parameters
Query
| Parameter | 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 the SQL ID from the DescribeOasTopSQLList, DescribeOasSlowSQLList, or DescribeOasAnomalySQLList API. |
6E05****E4D418C927918CDB62A0**** |
Body
| Parameter | Type | Required | Description | Example value |
|---|---|---|---|---|
| dbName | String | No | The name of the database. You can obtain the database name from the DescribeOasTopSQLList, DescribeOasSlowSQLList, or DescribeOasAnomalySQLList API. |
tf_**** |
| startTime | String | No | The start time. The value must be UTC time in the format of YYYY-MM-DDThh:mm:ssZ. | 2021-06-13T15:40:43Z |
| endTime | String | No | The end time. The value must be UTC time in the format of YYYY-MM-DDThh:mm:ssZ. | 2021-09-13T15:40:43Z |
Response parameters
| Parameter | Type | Description | Example value |
|---|---|---|---|
| data | JSON | The text of the SQL statement. | |
| dbName | String | The name of the database. | tf_**** |
| fulltext | String | The full text of the SQL 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 text of the SQL statement. | select sum(id), substring (name, 10, 21), sleep(?) from table_scan_index_not_used where name not like ?; |
| tables | Array | The table names parsed from the SQL statement. | ["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}/text
-H 'X-Ob-Project-Id: <Project ID>'
-G -d 'dbName=xx' -d 'startTime=xx' -d 'endTime=xxx'
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":{
"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
}