An SQL review optimization engine is integrated into the security rules of Data Management (DMS). After you submit SQL statements for data change or schema design, DMS can review the submitted SQL statements and offer optimization suggestions. This topic shows you how to use the SQL review optimization engine and customize security rules based on the engine.
Database change is essential to business development. Different developers have different technical skills for database development and the quality of SQL statements depends on their technical levels. In this case, the SQL statements must be reviewed.
To better perform manual review, experienced DBAs have formulated a series of schema research and development (R&D) specifications based on business needs and made the developers understand the specifications by means of oral presentations or training. However, the DBAs must repeat a large amount of review work every day and formulate more and more specifications. This increases the cost of manual review.
To resolve this issue, the SQL review optimization engine is supported in DMS and is closely integrated with processes such as schema design and data change. After a developer submits an SQL statement, the SQL review optimization engine checks whether the SQL statement conforms to the R&D specifications and assists the DBAs in reviewing the SQL statement. This way, the R&D quality can be improved. The R&D specifications cover items such as table properties, column properties, index properties, data query, and data change.
DMS predefines three behavioral actions:
- Must Improve: The engine stops the process and returns a message if the developer
does not optimize the SQL statement. Default SQL review rules in the system do not
contain Must Improve.
Note For more information about the check items of SQL review rules, see Check items.
Assume that you have set the behavioral action of the
Table must have primary keyrule to Must Improve. If a developer submits an SQL statement to create a table but does not specify a primary key for the table, the SQL review optimization engine stops the execution of the SQL statement and returns a message to request the developer to specify a primary key. After the modified SQL statement passes the verification, the system can execute it.
- Potential Issue: The engine reminds the developer that the SQL statement has potential issues, but does not stop the process.
- Suggest Improve: The engine suggests that the developer optimize the SQL statement, but does not stop the process.
Supported features in different control modes
DMS provides three control modes. For more information, see Control modes.
|Supported item||Security Collaboration||Stable Change||Flexible Management|
|Enable or disable a rule.||Supported||Supported||Supported|
|Set a behavioral action for a rule.||Supported||Not supported||Not supported|
|Modify the parameters of a rule.
You can specify parameters for part of rules, such as the number of indexes in a table and the number of fields in a table.
|Enter the description of a behavioral action.
You can enter the background of a behavioral action for a rule.
|Supported||Not supported||Not supported|
Security rules contain default SQL review rules. This example shows you how to customize
a security rule and set the behavioral action of the
Table must have primary key rule to Must Improve.
- Log on to the DMS console.
- In the top navigation bar, choose Security Rules tab appears.. The
- Find the security rule set that you want to modify and click Edit in the Actions column.
- In the left-side pane of the Details tab, click the SQL audit optimization recommendations tab.
- Find the
Table must have primary keyrule and click Edit in the Actions column.Note You can click the icon to the right of Tag, Behavioral action, or Status to filter rules. The Tag parameter specifies the effective range of a rule. A rule can apply to data definition language (DDL) statements and data manipulation language (DML) statements that are used to insert, delete, update, or query data. The Status parameter specifies whether a rule is enabled or disabled.
- In the Rule content configuration dialog box, set the parameters as required. The following table describes the parameters.
Parameter Description Behavioral action In this example, set the Behavioral action parameter to Must Improve.Note Default SQL review rules in the system do not contain Must Improve. Remarks Enter the description of the behavioral action for this rule, such as the background information.
- Click OK.
Note Assume that you have configured this SQL review rule. If a developer submits an SQL statement to create a table for an instance or modify a schema but the SQL statement does not comply with the
Table must have primary keyrule, the system automatically stops the process.
The following table describes the check items that are supported by the SQL review optimization engine.
|Scenario||Check item||Applicable SQL statement||Checkpoint|
||The character set of the database must be restricted.|
|Data change||Data insertion||
|Data update and deletion||