Skip to main content

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​

ParameterTypeRequiredDescription
dataSourceIdIntegerYesDataSource ID.
namespacePathArray of stringsYesFull namespace path. Each segment supports letters and their combining marks, numbers, underscores, hyphens, and dollar signs. See listNamespaces.
sqlStringYesSQL statement to execute.
maxRows32-bit positive integerNoMaximum rows to return per result set. Defaults to 1000. Values above 1000 are capped at 1000.

Response fields​

Fields in dataTypeDescription
resultsArray of objectsResults in the order the database returned them. An empty array indicates that the database returned no results.
results[].typeStringRESULT_SET (result set with columns, rows, and truncated), UPDATE_COUNT (affected row count with affectedRows).
results[].columnsArray of objectsColumn definitions for the result set.
results[].columns[].nameStringColumn name.
results[].columns[].typeStringDatabase column type.
results[].rowsTwo-dimensional arrayResult rows, with values in column order.
results[].truncatedBooleanWhether the result was truncated. The response body limit is 1 MiB.
results[].affectedRowsIntegerNumber 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
}
]
}
}