Purpose
This statement is used to create a fuzzy outline. You can create a fuzzy outline in two ways, by using the FORMAT_SQL_TEXT (the original statement with parameters executed by the user) or the FORMAT_SQL_ID value.
Limitations and considerations
You must log in as the user to create an outline.
If the
FORMAT_SQL_IDvalues are the same, the outline created by using theFORMAT_SQL_TEXTmethod will overwrite the one created by using theFORMAT_SQL_IDmethod, because the priority of theFORMAT_SQL_TEXTmethod is higher. OceanBase Database usesFORMAT_SQL_IDto distinguish between different SQL statements, which is generated by using theMD5hash encryption of theFORMAT_SQL_TEXTvalue after removing redundant spaces and line breaks and converting all characters to upper or lower case. We recommend that you useFORMAT_SQL_IDto bind an outline in a production system.Note
- The matching rule of
FORMAT_SQL_TEXTignores differences in parameter content, case, spaces, and line breaks, and compares only the text content after these differences are removed. FORMAT_SQL_IDis generated by applyingMD5hash encryption to the result afterFORMAT_SQL_TEXTis formatted (extra spaces and line breaks are removed, and all characters are converted to upper or lower case).
- The matching rule of
Syntax
/* Create an outline by using FORMAT_SQL_TEXT. */
CREATE [OR REPLACE] FORMAT OUTLINE outline_name ON format_stmt [ TO format_target_stmt ]
/* Create an outline by using FORMAT_SQL_ID. */
CREATE [OR REPLACE] FORMAT OUTLINE outline_name ON format_sql_id USING HINT hint;
Parameters
| Parameter | Description |
|---|---|
| outline_name | The name of the outline to be created. |
| OR REPLACE | If you specify OR REPLACE and the outline to be created already exists, the existing outline will be replaced. |
| format_stmt | The original SQL statement, which is the SQL statement or operation to which you want to apply the outline.
NoteOceanBase Database automatically formats the unformatted SQL statement. |
| TO format_target_stmt | Optional. Specifies the target SQL statement to which the format_stmt statement is converted or applied. You can use the TO format_target_stmt clause to declare these SQL statements.
Notice
|
| format_sql_id | The format_sql_id value of the SQL statement after it is rewritten by following a series of rules and the MD5 value of the format_stmt value. |
Examples
Create an outline by using the
FORMAT_SQL_TEXTvalue.CREATE FORMAT OUTLINE my_outline ON SELECT * FROM employees WHERE department_id = ?;Create an outline by using the
FORMAT_SQL_IDvalue.CREATE FORMAT OUTLINE my_sql_id_outline ON 'ED570339F2C856BA96008A29EDF04C74' USING HINT /*+ index(t1 idx_c2)*/;
References
For more information about outlines, see Plan binding.