All Products
Search
Document Center

Data Management:ExecuteScript

Last Updated:Nov 28, 2024

Executes SQL statements.

Operation description

You can call this operation only for instances that are managed in Security Collaboration mode.

Debugging

You can run this interface directly in OpenAPI Explorer, saving you the trouble of calculating signatures. After running successfully, OpenAPI Explorer can automatically generate SDK code samples.

Authorization information

The following table shows the authorization information corresponding to the API. The authorization information can be used in the Action policy element to grant a RAM user or RAM role the permissions to call this API operation. Description:

  • Operation: the value that you can use in the Action element to specify the operation on a resource.
  • Access level: the access level of each operation. The levels are read, write, and list.
  • Resource type: the type of the resource on which you can authorize the RAM user or the RAM role to perform the operation. Take note of the following items:
    • The required resource types are displayed in bold characters.
    • If the permissions cannot be granted at the resource level, All Resources is used in the Resource type column of the operation.
  • Condition Key: the condition key that is defined by the cloud service.
  • Associated operation: other operations that the RAM user or the RAM role must have permissions to perform to complete the operation. To complete the operation, the RAM user or the RAM role must have the permissions to perform the associated operations.
OperationAccess levelResource typeCondition keyAssociated operation
dms:ExecuteScriptupdate
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
DbIdintegerYes

The ID of the database.

Note This parameter is equivalent to the DatabaseId parameter in the SearchDatabase, ListDatabases, and GetDatabase operations. You can call one of these operations to obtain the required database ID. For more information, see SearchDatabase , ListDatabases , and GetDatabase .
123
ScriptstringYes

The SQL statements to be executed. Data query language (DQL) statements, data definition language (DDL) statements, and data manipulation language (DML) statements are supported. The control mode of the instance that you want to query determines whether you can execute DDL and DML statements.

select dt from report_daily
LogicbooleanYes

Specifies whether the database is a logical database.

false
TidlongNo

The ID of the tenant.

Note To obtain the tenant ID, move the pointer over the profile picture in the upper-right corner of the Data Management (DMS) console. For more information, see Tenant information.
234

Response parameters

ParameterTypeDescriptionExample
object
RequestIdstring

The ID of the request.

FE8EE2F1-4880-46BC-A704-5CF63EAF9A04
Resultsarray<object>

The results of the SQL statements that are executed, in the format of an array. Each entry in the array indicates the result of an SQL statement.

Resultobject
ColumnNamesarray

The fields that are queried after the SQL statement is executed.

ColumnNamesstring
col1
Rowsarray<object>

The rows that are queried after the SQL statement is executed.

Rowsobject
[{"col1": "value1", "col2":"value2"}]
Successboolean

Indicates whether the SQL statement is executed.

true
Messagestring

The error message that is returned if the SQL statement fails to be executed. For example, an error message is returned because the SQL statement is invalid.

UnknownError
RowCountlong

The total number of entries that are returned.

1
ErrorCodestring

The error code.

UnknownError
ErrorMessagestring

The error message about the gateway.

UnknownError
Successboolean

Indicates whether the request is successful.

true

Examples

Sample success responses

JSONformat

{
  "RequestId": "FE8EE2F1-4880-46BC-A704-5CF63EAF9A04",
  "Results": [
    {
      "ColumnNames": [
        "col1"
      ],
      "Rows": [
        [
          {
            "col1": "value1",
            "col2": "value2"
          }
        ]
      ],
      "Success": true,
      "Message": "UnknownError",
      "RowCount": 1
    }
  ],
  "ErrorCode": "UnknownError",
  "ErrorMessage": "UnknownError",
  "Success": true
}

Error codes

For a list of error codes, visit the Service error codes.

Change history

Change timeSummary of changesOperation
No change history