Queries SQL statements that were written on the SQLConsole tab.

Debugging

OpenAPI Explorer automatically calculates the signature value. For your convenience, we recommend that you call this operation in OpenAPI Explorer. OpenAPI Explorer dynamically generates the sample code of the operation for different SDKs.

Request parameters

Parameter Type Required Example Description
Action String Yes ListSQLExecAuditLog

The operation that you want to perform. Set the value to ListSQLExecAuditLog.

StartTime String Yes 2021-11-08 11:04:00

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.
EndTime String Yes 2021-11-08 11:00:00

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.
SearchName String No test_SearchName

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.
OpUserName String No test_OpUserName

The nickname of the user who wrote the SQL statement.

SqlType String No SELECT

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.
ExecState String No SUCCESS

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.
PageSize Integer Yes 20

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

PageNumber Integer Yes 1

The number of the page to return.

Tid Long No 3***

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

RegionId String No cn-hangzhou

The ID of the region in which Data Management (DMS) is activated. Set this parameter to the ID of the region that is in proximity to your applications. For more information about the valid values of this parameter, see RegionID parameter.

Response parameters

Parameter Type Example Description
TotalCount Long 1

The number of entries returned.

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

The ID of the request.

ErrorCode String MissingStartTime

The error code returned.

ErrorMessage String StartTime is mandatory for this action.

The error message returned.

Success Boolean true

Indicates whether the request was successful. Valid values:

  • true: The request was successful.
  • false: The request failed.
SQLExecAuditLogList Array of SQLExecAuditLog

The entries returned.

SQLExecAuditLog
OpTime String 2021-11-08 11:04:27

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

UserName String test_UserName

The nickname of the user who wrote the SQL statement.

UserId Long 12****

The ID of the user who wrote the SQL statement.

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

The name of the database.

Note If the SQL statement takes effect on an instance, the name of the instance is returned.
InstanceId Long 185***

The ID of the instance.

SchemaName String polar123

The name of the database.

DbId Long 2157****

The ID of the database.

Logic Boolean false

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

  • true: The database is a logical database.
  • false: The database is a physical database.
SQLType String SELECT

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.
SQL String SELECT * FROM `polar123`.`p_qw` ORDER BY `id` DESC

The SQL statement that was written.

ExecState String SUCCESS

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.
AffectRows Long 2

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.

ElapsedTime Long 18

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

Remark String success

The comment on the SQL statement.

Examples

Sample request

http(s)://dms-enterprise.aliyuncs.com/?Action=ListSQLExecAuditLog
&StartTime=2021-11-08 11:04:00
&EndTime=2021-11-08 11:00:00
&SearchName=test_SearchName
&OpUserName=test_OpUserName
&SqlType=SELECT
&ExecState=SUCCESS
&PageSize=20
&PageNumber=1
&Tid=3***
&<Common request parameters>

Sample success responses

XML format

HTTP/1.1 200 OK
Content-Type:application/xml

<ListSQLExecAuditLogResponse>
    <TotalCount>1</TotalCount>
    <RequestId>39BC****-95AE-58F2-9862-A7C3D896****</RequestId>
    <Success>true</Success>
    <SQLExecAuditLogList>
        <SQLExecAuditLog>
            <UserName>test_UserName</UserName>
            <InstanceId>185****</InstanceId>
            <ElapsedTime>18</ElapsedTime>
            <ExecState>SUCCESS</ExecState>
            <OpTime>2021-11-08 11:04:27</OpTime>
            <SQL>SELECT * FROM `polar123`.`p_qw` ORDER BY `id` DESC</SQL>
            <Remark/>
            <InstanceName>polar123@pc-bp1h9tgq4st9g****.mysql.polardb.rds.aliyuncs.com:3306[polar_qw_test]</InstanceName>
            <UserId>12****</UserId>
            <DbId>2157****</DbId>
            <Logic>false</Logic>
            <SQLType>SELECT</SQLType>
            <SchemaName>polar123</SchemaName>
            <AffectRows>2</AffectRows>
        </SQLExecAuditLog>
    </SQLExecAuditLogList>
</ListSQLExecAuditLogResponse>

JSON format

HTTP/1.1 200 OK
Content-Type:application/json

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

Error codes

For a list of error codes, visit the API Error Center.