All Products
Search
Document Center

Data Management:ListSQLExecAuditLog

Last Updated:Aug 27, 2026

Queries the audit logs of SQL statements that are executed in Data Management (DMS).

Try it now

Try this API in OpenAPI Explorer, no manual signing needed. Successful calls auto-generate SDK code matching your parameters. Download it with built-in credential security for local usage.

Test

RAM authorization

The table below describes the authorization required to call this API. You can define it in a Resource Access Management (RAM) policy. The table's columns are detailed below:

  • Action: The actions can be used in the Action element of RAM permission policy statements to grant permissions to perform the operation.

  • API: The API that you can call to perform the action.

  • Access level: The predefined level of access granted for each API. Valid values: create, list, get, update, and delete.

  • Resource type: The type of the resource that supports authorization to perform the action. It indicates if the action supports resource-level permission. The specified resource must be compatible with the action. Otherwise, the policy will be ineffective.

    • For APIs with resource-level permissions, required resource types are marked with an asterisk (*). Specify the corresponding Alibaba Cloud Resource Name (ARN) in the Resource element of the policy.

    • For APIs without resource-level permissions, it is shown as All Resources. Use an asterisk (*) in the Resource element of the policy.

  • Condition key: The condition keys defined by the service. The key allows for granular control, applying to either actions alone or actions associated with specific resources. In addition to service-specific condition keys, Alibaba Cloud provides a set of common condition keys applicable across all RAM-supported services.

  • Dependent action: The dependent actions required to run the action. To complete the action, the RAM user or the RAM role must have the permissions to perform all dependent actions.

Action

Access level

Resource type

Condition key

Dependent action

dms:ListSQLExecAuditLog

list

*All Resource

*

None None

Request parameters

Parameter

Type

Required

Description

Example

StartTime

string

Yes

The beginning of the time range to query.

Note

The start time supports fuzzy match. Specify the time in the YYYY-MM-DD hh:mm:ss format.

2021-11-08 11:04:00

EndTime

string

Yes

The end of the time range to query.

Note

The end time supports fuzzy match. Specify the time in the YYYY-MM-DD hh:mm:ss format. We recommend that you use the StartTime and EndTime parameters to specify a time range that does not exceed one day. The returned entries can be displayed by page to improve query efficiency.

2021-11-08 11:00:00

SearchName

string

No

The name of the database or instance based on which you want to query SQL statements.

Note

If the SQL statements to be queried are at the instance level, you can set this parameter to an instance name. If the SQL statements to be queried are at the database level, you can set this parameter to a database name.

test_SearchName

OpUserName

string

No

The nickname of the user who wrote the SQL statement.

test_OpUserName

SqlType

string

No

The type of the SQL statement. Valid values:

  • SELECT: the SQL statement that is used to query data.

  • INSERT: the SQL statement that is used to insert data.

  • DELETE: the SQL statement that is used to delete data.

  • CREATE_TABLE: the SQL statement that is used to create tables.

Note

To view more types of SQL statements, log on to the DMS console and click Security and Specifications. In the left-side navigation pane, click Operation Audit. Then, you can view all supported types of SQL statements from the SQL type drop-down list.

SELECT

ExecState

string

No

The execution status of the SQL statement. Valid values:

  • FAIL: The SQL statement fails to be executed.

  • NOEXE: The SQL statement has not been executed.

  • RUNNING: The SQL statement is being executed.

  • CANCEL: The execution of the SQL statement is canceled.

  • SUCCESS: The SQL statement is executed.

1

PageSize

integer

No

The number of entries to return on each page. The value cannot exceed 100.

20

PageNumber

integer

No

The number of the page to return.

1

Tid

integer

No

The ID of the tenant. You can call the GetUserActiveTenant operation to obtain the tenant ID.

3***

Response elements

Element

Type

Description

Example

object

TotalCount

integer

The number of entries returned.

1

RequestId

string

The ID of the request.

39BC9C86-95AE-58F2-9862-A7C3D896****

ErrorCode

string

The error code returned.

MissingStartTime

ErrorMessage

string

The error message returned.

StartTime is mandatory for this action.

Success

boolean

Indicates whether the request was successful. Valid values:

  • true: The request was successful.

  • false: The request failed.

true

SQLExecAuditLogList

object

SQLExecAuditLog

array<object>

The entries returned.

object

OpTime

string

The time when the operation specified by the SQL statement was performed on the instance or database.

2021-11-08 11:04:27

UserName

string

The nickname of the user who wrote the SQL statement.

test_UserName

UserId

integer

The ID of the user who wrote the SQL statement.

12****

InstanceName

string

The name of the database.

Note

If the SQL statement takes effect on an instance, the name of the instance is returned.

polar123@pc-bp1h9tgq4st9g****.mysql.polardb.rds.aliyuncs.com:3306[polar_qw_test]

InstanceId

integer

The ID of the instance.

185***

SchemaName

string

The name of the database.

polar123

DbId

integer

The ID of the database.

2157****

Logic

boolean

Indicates whether the database is a logical database. Valid values:

  • true: The database is a logical database.

  • false: The database is a physical database.

false

SQLType

string

The type of the SQL statement. Valid values:

  • SELECT: the SQL statement that is used to query data.

  • INSERT: the SQL statement that is used to insert data.

  • DELETE: the SQL statement that is used to delete data.

  • CREATE_TABLE: the SQL statement that is used to create tables.

Note

To view more types of SQL statements, log on to the DMS console and click Security and Specifications. In the left-side navigation pane, click Operation Audit. Then, you can view all supported types of SQL statements from the SQL type drop-down list.

SELECT

SQL

string

The SQL statement that was written.

SELECT * FROM `polar123`.`p_qw` ORDER BY `id` DESC

ExecState

string

The execution status of the SQL statement. Valid values:

  • FAIL: The SQL statement fails to be executed.

  • NOEXE: The SQL statement has not been executed.

  • RUNNING: The SQL statement is being executed.

  • CANCEL: The execution of the SQL statement is canceled.

  • SUCCESS: The SQL statement is executed.

SUCCESS

AffectRows

integer

The number of rows affected by the SQL statement. For example, if you execute an SQL statement to query data, the number of retrieved rows is returned.

2

ElapsedTime

integer

The amount of time consumed by the execution of the SQL statement. Unit: milliseconds.

18

Remark

string

The comment on the SQL statement.

success

Examples

Success response

JSON format

{
  "TotalCount": 1,
  "RequestId": "39BC9C86-95AE-58F2-9862-A7C3D896****",
  "ErrorCode": "MissingStartTime",
  "ErrorMessage": "StartTime is mandatory for this action.",
  "Success": true,
  "SQLExecAuditLogList": {
    "SQLExecAuditLog": [
      {
        "OpTime": "2021-11-08 11:04:27",
        "UserName": "test_UserName",
        "UserId": 0,
        "InstanceName": "polar123@pc-bp1h9tgq4st9g****.mysql.polardb.rds.aliyuncs.com:3306[polar_qw_test]",
        "InstanceId": 0,
        "SchemaName": "polar123",
        "DbId": 0,
        "Logic": false,
        "SQLType": "SELECT",
        "SQL": "SELECT * FROM `polar123`.`p_qw` ORDER BY `id` DESC",
        "ExecState": "SUCCESS",
        "AffectRows": 2,
        "ElapsedTime": 18,
        "Remark": "success"
      }
    ]
  }
}

Error codes

See Error Codes for a complete list.

Release notes

See Release Notes for a complete list.