Execute a data operation
Execute one SQL statement. Supports queries, writes, and schema changes.
POST /api/open/v1/data/executeOperation
Requires “Query Console Access” and operation permissions on the target resources. SQL rules and data masking policies apply.
SQL runs in auto-commit mode with a time limit of up to 25 seconds. After a write times out, check the database state before retrying.
Request parameters
| Parameter | Type | Required | Description |
|---|---|---|---|
| dataSourceId | Integer | Yes | DataSource ID. |
| namespacePath | Array of strings | Yes | Full namespace path. Each segment supports letters and their combining marks, numbers, underscores, hyphens, and dollar signs. See listNamespaces. |
| sql | String | Yes | SQL statement to execute. |
| maxRows | 32-bit positive integer | No | Maximum rows to return per result set. Defaults to 1000. Values above 1000 are capped at 1000. |
Response fields
| Fields in data | Type | Description |
|---|---|---|
| results | Array of objects | Results in the order the database returned them. An empty array indicates that the database returned no results. |
| results[].type | String | RESULT_SET (result set with columns, rows, and truncated), UPDATE_COUNT (affected row count with affectedRows). |
| results[].columns | Array of objects | Column definitions for the result set. |
| results[].columns[].name | String | Column name. |
| results[].columns[].type | String | Database column type. |
| results[].rows | Two-dimensional array | Result rows, with values in column order. |
| results[].truncated | Boolean | Whether the result was truncated. The response body limit is 1 MiB. |
| results[].affectedRows | Integer | Number of affected rows reported by the database. |
Request example (MySQL)
{
"dataSourceId": 42,
"namespacePath": [
"sales"
],
"sql": "SELECT item_id, item_name FROM items ORDER BY item_id LIMIT 5",
"maxRows": 5
}
Response example
{
"requestId": "daa3a83b-c028-502b-b71a-d19412096187",
"code": "OK",
"msg": "Request succeeded.",
"data": {
"results": [
{
"type": "RESULT_SET",
"columns": [
{
"name": "item_id",
"type": "BIGINT"
},
{
"name": "item_name",
"type": "VARCHAR"
}
],
"rows": [
[
1001,
"Sample product"
]
],
"truncated": false
}
]
}
}