All Products
Search
Document Center

Data Management:ListSQLExecAuditLog

Last Updated:Nov 28, 2024

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

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:ListSQLExecAuditLoglist
*All Resources
*
    none
none

Request parameters

ParameterTypeRequiredDescriptionExample
StartTimestringYes

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
EndTimestringYes

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
SearchNamestringNo

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
OpUserNamestringNo

The nickname of the user who wrote the SQL statement.

test_OpUserName
SqlTypestringNo

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
ExecStatestringNo

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
PageSizeintegerYes

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

20
PageNumberintegerYes

The number of the page to return.

1
TidlongNo

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

3***

Response parameters

ParameterTypeDescriptionExample
object
TotalCountlong

The number of entries returned.

1
RequestIdstring

The ID of the request.

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

The error code returned.

MissingStartTime
ErrorMessagestring

The error message returned.

StartTime is mandatory for this action.
Successboolean

Indicates whether the request was successful. Valid values:

  • true: The request was successful.
  • false: The request failed.
true
SQLExecAuditLogListarray<object>

The entries returned.

SQLExecAuditLogobject
OpTimestring

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

2021-11-08 11:04:27
UserNamestring

The nickname of the user who wrote the SQL statement.

test_UserName
UserIdlong

The ID of the user who wrote the SQL statement.

12****
InstanceNamestring

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]
InstanceIdlong

The ID of the instance.

185***
SchemaNamestring

The name of the database.

polar123
DbIdlong

The ID of the database.

2157****
Logicboolean

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
SQLTypestring

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
SQLstring

The SQL statement that was written.

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

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
AffectRowslong

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
ElapsedTimelong

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

18
Remarkstring

The comment on the SQL statement.

success

Examples

Sample success responses

JSONformat

{
  "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

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

Change history

Change timeSummary of changesOperation
2023-03-23The internal configuration of the API is changed, but the call is not affectedView Change Details