Queries the audit logs of SQL statements that are executed in Data Management (DMS).
Try it now
Test
RAM authorization
|
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:
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:
|
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 |
| 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:
|
false |
| SQLType |
string |
The type of the SQL statement. Valid values:
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:
|
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.