ALTER_SQL_PLAN_BASELINE is used to modify the attributes of one or more plans in a baseline. The return value indicates the number of modified baselines.
Syntax
DBMS_SPM.ALTER_SQL_PLAN_BASELINE (
sql_handle IN VARCHAR,
plan_name IN VARCHAR := NULL,
attribute_name IN VARCHAR,
attribute_value IN VARCHAR
)
RETURN PLS_INTEGER;
Parameters
| Parameter | Description |
|---|---|
| database_name | The name of the database. This parameter is required only in MySQL-compatible mode. |
| sql_handle | The identifier of the SQL statement, which is also known as SQL_ID. |
| plan_name | The name of the plan, which is also known as Plan Hash Value. If the value is NULL, all evolving plans of the SQL statement are accepted. |
| attribute_name | The name of the plan attribute. Please see Attribute description. |
| attribute_value | The value of the plan attribute. Please see Attribute description. |
Attribute description
| Attribute | Permissible values | Description |
|---|---|---|
| enabled | 'YES' or 'NO' | 'YES' specifies that the plan baseline is valid. Whether the plan baseline is used depends on acceptance. |
| fixed | 'YES' or 'NO' | 'YES' specifies that the current plan baseline is preferentially used and not automatically evolved. |
| autopurge | 'YES' or 'NO' | 'YES' specifies that the plan baseline will be automatically discarded if it is not used for a period of time; 'NO' specifies that the plan baseline will never be discarded. |
| plan_name | A string with a maximum of 30 characters. | The name of the plan. |
| description | A string with a maximum of 500 bytes. | The description of the plan. |
Examples
You can fix a plan baseline so that the SQL statement uses only the specified plan.
DECLARE
v_alter_plans NUMBER;
BEGIN
v_alter_plans := DBMS_SPM.ALTER_SQL_PLAN_BASELINE(
sql_handle => '529F6E6454EF579C7CC265D1F6131D70',
plan_name => '3388268709115914355',
attribute_name => 'fixed',
attribute_value => 'YES' );
END;
/