High-risk SQL statements are those that may harm system performance, security, and data.
Background information
High-risk SQL statements are divided into the following two categories:
SQL statements that return more than 50,000 rows, affect more than 50,000 rows, or involve more than 50 partitions
SQL statements that meet the following conditions:
- DROP TABLE or DROP DATABASE
- TRUNCATE TABLE
- ALTER TABLE
- ADD COLUMN or DROP COLUMN
- UPDATE TABLE without a WHERE clause or with a WHERE clause that always evaluates to true
- DELETE FROM without a WHERE clause or with a WHERE clause that always evaluates to true
Query the list of high-risk SQL statements
Log in to the OceanBase Cloud console.
In the left-side navigation pane, click Instances.
In the instance list, find the target instance, click the instance name, and go to the Overview page of the instance.
Click Diagnostics in the left-side navigation pane, and then select the SQL tab on the Diagnostics page.
On the SQL tab, select High-risk SQL.
(Optional) Configure the filter conditions.
Database: Select any database in the current cluster.
Time range: You can view data in the following time ranges: Past 5 Minutes, Past 30 Minutes, Past 1 Hour, Past 3 Hours, and Past 6 Hour(s). You can also customize the time range, with a maximum of 15 days. However, note the following limitations:
- Maximum range limit: The selected time range must not exceed 24 hours.
- Minimum range limit:
- For data within 3 days: The selected time range must be at least 1 minute.
- For data from 3 to 7 days: The selected time range must be at least 5 minutes.
- For data beyond 7 days: The selected time range must be at least 20 minutes.
SQL ID: Enter the SQL ID to be queried. You can enter multiple IDs and separate them with half-width characters , or ;.
SQL text: Enter the SQL text keyword to be queried. The query results will display the SQL containing the keyword in the SQL text. Constant search is not supported.
More Conditions: Click +Add, and in the Add More Conditions panel, configure the metrics, operators, and metric values. When you perform a query, the SQL that meets the metric conditions will be displayed in the query result list.
Click Query.
By default, the High-risk SQL tab displays the following metrics: SQL text, Database, User, SQL Type, Request IP Address, and Causes of Risk.
You can filter the SQL text by Database, User, and SQL Type.
You can sort the SQL text by Request IP Address.
Click ..., and then click Download Table to download the high-risk SQL statement list.
Click the icon
to query more metrics in the Manage Columns window that pops up.