The search feature allows you to query and export information about SQL statements. This topic describes how to use the search feature in the SQL Explorer and Audit module.

Prerequisites

  • The database instance that you want to manage is connected to DAS and is in the Accessed state.
  • DAS Professional Edition is enabled for the database instance. For more information, see Purchase DAS Professional Edition.
  • The SQL Explorer and Audit feature is available only for the following types of databases:
    • ApsaraDB RDS for MySQL High-availability Edition and Enterprise Edition
    • ApsaraDB RDS for SQL Server High-availability Edition and Cluster Edition
    • ApsaraDB RDS for PostgreSQL High-availability Edition
    • PolarDB for MySQL Single Node Edition, Archive Database Edition, and Cluster Edition
    • PolarDB-X 2.0
  • The SQL Explorer and Audit feature is available in different regions for different types of databases.
    Database type Region
    • ApsaraDB RDS for MySQL High-availability Edition and Enterprise Edition
    • ApsaraDB RDS for SQL Server High-availability Edition and Cluster Edition
    • PolarDB for MySQL Single Node Edition, Archive Database Edition, and Cluster Edition
    China (Hangzhou), China (Shanghai), China (Qingdao), China (Beijing), China (Shenzhen), China (Zhangjiakou), China (Hohhot), China (Chengdu), China (Guangzhou), China (Heyuan), China (Ulanqab), China (Hong Kong), Singapore (Singapore), Malaysia (Kuala Lumpur), and Indonesia (Jakarta)
    ApsaraDB RDS for PostgreSQL High-availability Edition China (Hangzhou), China (Shanghai), China (Beijing), China (Shenzhen), China (Zhangjiakou), Singapore (Singapore), Malaysia (Kuala Lumpur), and Indonesia (Jakarta)
    PolarDB-X 2.0 China (Hangzhou), China (Shanghai), China (Beijing), China (Shenzhen), and Singapore (Singapore)

Procedure

  1. Log on to the DAS console.
  2. In the left-side navigation pane, click Instance Monitoring.
  3. On the Instance Monitoring page, click the name of the instance that you want to manage. The instance details page appears.
  4. In the left-side navigation pane of the page, choose Request Analysis > SQL Explorer and Audit. Then, on the Search tab, configure the following parameters to set the query conditions.
    Parameter Description
    Time Range

    Specify the time range during which to query executed SQL statements.

    The maximum time range is 24 hours. The start time must be within the time range during which logs generated by SQL Explorer for the database instance are retained. The time range is limited to 24 hours for performance considerations. The SQL Explorer feature records all operations that are performed on your database instances, which results in a large number of SQL statements in the generated logs. If the specified time range is excessively long, the query may take a long time to run or even time out.
    Note If you want to query SQL statements over a time range that exceeds 24 hours, we recommend that you export log files to your device.
    Keyword You can specify multiple keywords that are separated by spaces. Fuzzy queries are not supported.
    Note Each keyword must contain at least four characters.
    User You can specify multiple usernames that are separated by spaces. Example: user1 user2 user3.
    Database You can specify multiple database names that are separated by spaces. Example: DB1 DB2 DB3.
    Operation Type Select the operation types to query. You can select one or more operation types.
    Note You can click Enable Advanced Query to specify more parameters to further refine the query.
  5. Click Query. Then, you can view the information about SQL statements in the Logs section.
    To export logs, click Export and specify Exported Fields.
    Note Set Export Time Range to export logs generated both within and beyond a time range of 24 hours.
    s