You need to enable JavaScript to run this app.
Database Workshop

Database Workshop

Copy page
Download PDF
SQL task
ExecuteSQL
Copy page
Download PDF
ExecuteSQL
Call the ExecuteSQL API to execute SQL statements.​
tip​
  • This API does not support OnlineDDL actions. Using this API to execute DDL operations may cause DML, DQL, and other operations to be blocked. Use with caution.​
  • This API does not support RDS for PostgreSQL and RDS for SQL Server databases.​
Request type​
Synchronize request.​
Request parameters​
​
Name​
Type​
Required?​
Sample​
Description​
InstanceID​
String​
Yes​
mysql-bf120f******​
Database instance ID​
tip​
You can select the following APIs to query the instance ID as needed:​
InstanceType​
String​
Yes​
MySQL​
Database types. The following database types are supported:​
  • MySQL: RDS for MySQL.​
  • VeDBMySQL: veDB for MySQL.​
  • Mongo: Document Database for MongoDB.​
  • Redis: Cache for Redis.​
Database​
String​
Yes​
mysql​
Database name. Specifies to execute SQL command in a database. If not specified, the SQL command is executed in the current database by default.​
Commands​
String​
Yes​
select * from func;​
SQL text.​
tip​
  • When the database type is MySQL or veDBMySQL, if you need to execute multiple SQL statements, you can separate them with a semicolon (;).​
  • When the database type is Redis, if you need to execute multiple SQL statements, you can separate them with \r\n.​
  • When the database type is Document Database for MongoDB, executing multiple SQL statements is not supported. Only one SQL statement can be included in the SQL text.​
TimeOutSeconds​
Integer​
No​
300​
SQL command timeout. Unit: seconds (s). The default is 300 seconds.​
​
Response parameters​
​
Name​
Type​
Sample​
Description​
Results​
Array of ResultObject​
The result of executing the SQL command.​
​
Request example​
​
POST /?Action=ExecuteSQL&Version=2018-01-01 HTTP/1.1​
Accept: application/json​
Content-Type: application/json​
Host: dbw.volcengineapi.com​
X-Date: 20210328T100802Z​
Authorization: HMAC-SHA256 Credential=AKLTYmYwNjAzYjFmMjRkNDQwZWI4MzI1MzhjZGYyM******/20210328/cn-beijing/dbw/request, SignedHeaders=x-date, Signature=e1d274292f8b36eb096e1d2fec02822bd2e5cb3435699938adb7341861******​
​
{​
"InstanceID": "mysql-bf120f******",​
"InstanceType": "MySQL",​
"Database": "company",​
"Commands": "select * from func;"​
}​
​
Response example​
​
{​
"ResponseMetadata": {​
"RequestId": "202309221612539B33ED77F0A06214EB4A",​
"Action": "ExecuteSQL",​
"Version": "2018-01-01",​
"Service": "dbw",​
"Region": "cn-beijing"​
},​
"Result": {​
"Results": [​
{​
"ColumnNames": [​
"opid",​
"opcode",​
"opname",​
"ophref",​
"opseq"​
],​
"CommandStr": "Select * from auth_operation",​
"ReasonDetail": "",​
"RowCount": 2,​
"Rows": [​
{​
"Cells": [​
"87",​
"01",​
"权限管理",​
"/admin/auth",​
"1"​
]​
},​
{​
"Cells": [​
"98",​
"010205",​
"角色权限管理页面",​
"/admin/role/bindOperPage/{roleid}",​
"1"​
]​
}​
],​
"RunTime": 1695370373000,​
"State": "Success"​
}​
]​
}​
}​
​
Error code​
For details, refer to Error codes.​
Last updated: 2025.11.28 18:18:32