All Products
Search
Document Center

PolarDB:SQL audit

Last Updated:Mar 28, 2026

Use SQL audit to search SQL execution history, investigate slow queries or security incidents, and export log records for compliance review.

Prerequisites

Before you begin, ensure that you have:

Query and export SQL logs

  1. Click the Audit tab and select the nodes to audit.

    Note

    To set the storage duration of SQL logs, click Service Settings.

  2. Set your query conditions using Set Query Conditions or Enable Advanced Query, then click Query. The following parameters are available:

    ParameterDescriptionInput format
    Time rangeFilters by SQL statement execution durationSelect a start and end time
    KeywordFilters by keywords in the SQL statementEnter one or more keywords separated by spaces. Select OR to match any keyword, or AND to require all keywords
    UserFilters by database account nameEnter one or more account names separated by spaces
    DatabaseFilters by database nameEnter one or more database names separated by spaces
    Operation typeFilters by SQL operation typeSelect one or more: SELECT, INSERT, UPDATE, DELETE, LOGIN, LOGOUT, MERGE, ALTER, CREATE, DROP, SET, DESC, REPLACE, CALL, BEGIN, DESCRIBE, ROLLBACK, FLUSH, USE, SHOW, START, COMMIT, RENAME, TRUNCATE
    Client IP addressFilters by the IP address of the client that ran the SQL statementEnter one or more IP addresses separated by spaces
    Execution statusFilters by whether execution succeededSelect Completed, Failed, or both
    Execution durationFilters by how long the SQL statement took to runEnter a range in milliseconds, for example, 100-5000
    Updated/returned rowsFilters by the number of rows updated or returnedEnter a range, for example, 0-1000
    Physical SQL statementsFilters by the number of SQL statements actually executedEnter a value
    Tracking IDFilters by the request ID between the compute node and data nodeCopy the tracking ID from a log record in your query results
    Transaction IDFilters by the transaction ID generated during executionCopy the transaction ID from a log record in your query results
    SQL IDFilters by the SQL template IDEnter one or more SQL IDs separated by spaces. Find SQL IDs in SQL Explorer

    image

  3. (Optional) To export log records, click Export, select the Export Fields to include, and set an Export Time Range if you need records beyond the current query window.

    Note

    To check the status of recent export tasks, click View Export List.