All Products
Search
Document Center

PolarDB:SQL audit

Last Updated:May 19, 2025

The SQL audit feature allows you to query and export various information related to SQL statements, such as databases, states, and runtime.

Prerequisites

Procedure

  1. Click the Audit tab and select the nodes that you want to audit.

    Note

    Click Service Settings to set the storage duration of SQL logs.

  2. Set Query Conditions or Enable Advanced Query, and then click Query.

    image

    The parameters on the tab:

    Parameter

    Description

    Time Range

    The execution duration of the SQL statement.

    Keyword

    One or more keywords contained in the SQL statement. Separate multiple keywords with spaces ( ). You can choose the following logical relationship between these keywords:

    • OR: The filtered SQL statement can be retrieved if it contains one or more of the specified keywords.

    • AND: The filtered SQL statement can be retrieved only if it contains all the specified keywords.

    User

    The name of the database account. Multiple database accounts can be filtered together. Separate multiple database account names with spaces ( ).

    Database

    The database name. Multiple databases can be filtered together. Separate multiple database names with spaces ( ).

    Operation Type

    Filter by SQL operation type. You can select one or more operation types from SELECT, INSERT, UPDATE, DELETE, LOGIN, LOGOUT, MERGE, ALTER, CREATE, DROP, SET, DESC, REPLACE, CALL, BEGIN, DESCRIBE, ROLLBACK, FLUSH, USE, SHOW, START, COMMIT, RENAME, and TRUNCATE.

    Client IP Address

    The remote client IP that executes the SQL statement. Separate multiple client IP addresses with spaces ( ).

    Execution Status

    Filter by whether the SQL execution is successful. You can select both Completed and Failed.

    Execution Duration

    The SQL execution duration in milliseconds. You can specify a range.

    Updated/returned rows

    The number of rows updated or returned after the execution. You can specify a range.

    Physical SQL Statements

    The number of SQL statements actually executed.

    Tracking ID

    The ID of request between the compute node and the data node. You can obtain it from the query results (log records).

    Transaction ID

    The transaction ID generated in the execution. You can obtain it from the query results (log records).

    SQL ID

    The SQL template ID. Separate multiple SQL template IDs with spaces ( ). You can obtain it from SQL Explorer.

  3. (Optional) Click Export, select the required Export Fields to export SQL log records. You can export SQL records for a longer time range by setting the Export Time Range.

    Note

    Click View Export List to view the list of recent export tasks.