High-risk SQL refers to SQL statements in the database that may pose a threat to system performance, security, and data integrity.
Background information
High-risk SQL statements are divided into two categories:
SQL statements that return more than 50,000 rows, affect more than 50,000 rows, or participate in more than 500 partitions
SQL statements that meet the following conditions:
- drop table/database
- truncate table
- alter table
- add/drop column
- update table without conditions or when the conditions are always true
- delete from without conditions or when the conditions are always true
View the high-risk SQL list
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 Real-Time Diagnostics tab on the Diagnostics page.
On the SQL tab, select High-risk SQL.
(Optional) Configure filter conditions.
Database: Select any database in the current cluster.
Time Range: View the data of the Last 5 Minutes, Last 30 Minutes, Last 1 Hour, Last 3 Hours, or Last 6 Hours. You can also customize the time range (up to 15 days), but please 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 metric, operator, and value. When querying, the SQL that satisfies the metric conditions will be displayed in the query result list.
Click Query.
The High-risk SQL tab displays the following metrics by default: SQL Text, Database, User, SQL Type, Request IP Address, and Cause of Risk.
Filter the SQL text by Database, User, and SQL Type.
Sort the SQL text by Request IP Address.
Click ..., and then click Download Table to download the high-risk SQL list.
Click the icon
to query more metrics in the Manage Columns window that pops up.