29 DBMS_AUTO_INDEX
The DBMS_AUTO_INDEX
package provides the interface for managing auto indexes in an Oracle database.
This chapter contains the following topics:
29.1 DBMS_AUTO_INDEX Overview
The DBMS_AUTO_INDEX
package is the interface for configuring auto indexes and generating reports of auto indexing operations in an Oracle database.
29.2 Summary of DBMS_AUTO_INDEX Subprograms
This table lists the DBMS_AUTO_INDEX
package subprograms and briefly describes them.
Table 29-1 DBMS_AUTO_INDEX Package Subprograms
Procedure | Description |
---|---|
Configures settings related to automatic indexing. |
|
Deletes all the indexes, except the ones used for constraints, from a schema or a table. |
|
Returns a report of the automatic indexing operations executed during a specific period in a database. |
|
Returns a report of the last automatic indexing operation executed in a database. |
29.2.1 CONFIGURE Procedure
This procedure configures settings related to automatic indexing.
Syntax
DBMS_AUTO_INDEX.CONFIGURE (
parameter_name IN VARCHAR2,
parameter_value IN VARCHAR2,
allow IN BOOLEAN DEFAULT TRUE);
Parameters
Table 29-2 CONFIGURE Procedure Parameters
Parameter | Description |
---|---|
|
Automatic indexing configuration setting. It can have one of the following values:
|
|
Value for the configuration setting specified in When it is set to |
|
This parameter is applicable only for the
Refer to the description of the |
Examples
These examples are based on the assumption that the inclusion list and the exclusion list are initially empty.
The following example adds the SH
and HR
schemas to the exclusion list, so that only the SH
and HR
schemas cannot use auto indexes.
begin dbms_auto_index.configure( parameter_name => 'AUTO_INDEX_SCHEMA', parameter_value => 'SH', allow => FALSE); dbms_auto_index.configure( parameter_name => 'AUTO_INDEX_SCHEMA', parameter_value => 'HR', allow => FALSE); end;
The following example removes the HR
schema from the exclusion list, so that it can also use auto indexes. Now, only the SH
schema cannot use auto indexes, because it is the only schema added to the exclusion list.
begin dbms_auto_index.configure( parameter_name => 'AUTO_INDEX_SCHEMA', parameter_value => 'HR', allow => NULL); end;
The following example removes all the schemas from the exclusion list, so that all the schemas can use auto indexes.
begin dbms_auto_index.configure( parameter_name => 'AUTO_INDEX_SCHEMA', parameter_value => NULL, allow => TRUE); end;
The following example adds the HR
schema to the inclusion list, so that only the HR
schema can use auto indexes.
begin dbms_auto_index.configure( parameter_name => 'AUTO_INDEX_SCHEMA', parameter_value => 'HR', allow => TRUE); end;
The following example sets the retention period for auto indexes to 90 days.
begin dbms_auto_index.configure( parameter_name => 'AUTO_INDEX_RETENTION_FOR_AUTO', parameter_value => '90'); end;
The following example sets the retention period for auto indexes to the default value of 373 days.
begin dbms_auto_index.configure( parameter_name => 'AUTO_INDEX_RETENTION_FOR_AUTO', parameter_value => NULL); end;
29.2.2 DROP_SECONDARY_INDEXES Procedure
This procedure deletes all the indexes, except the ones used for constraints, from a schema or a table.
Syntax
DBMS_AUTO_INDEX.DROP_SECONDARY_INDEXES (
ownname IN VARCHAR2 DEFAULT NULL,
tabname IN VARCHAR2 DEFAULT NULL);
Parameters
Table 29-3 DROP_SECONDARY_INDEXES Procedure Parameters
Parameter | Description |
---|---|
|
(Optional) Name of the schema from which all the indexes need to be deleted. Note: The indexes used for constraints are not deleted. |
|
(Optional) Name of the table from which all the indexes need to be deleted. Note: The indexes used for constraints are not deleted. |
Examples
The following example deletes all the indexes, except the ones used for constraints, from the SH
schema.
begin dbms_auto_index.drop_secondary_indexes('SH'); end;
The following example deletes all the indexes, except the ones used for constraints, from the EMP
table in the HR
schema.
begin dbms_auto_index.drop_secondary_indexes('HR', 'EMP'); end;
The following example deletes all the indexes, except the ones used for constraints, for which the user has the delete privileges from all the schemas in a database.
begin dbms_auto_index.drop_secondary_indexes; end;
29.2.3 REPORT_ACTIVITY Function
This function returns a report of the automatic indexing operations executed during a specific period in a database.
Syntax
DBMS_AUTO_INDEX.REPORT_ACTIVITY (
activity_start IN TIMESTAMP WITH TIME ZONE DEFAULT SYSTIMESTAMP - 1,
activity_end IN TIMESTAMP WITH TIME ZONE DEFAULT SYSTIMESTAMP,
type IN VARCHAR2 DEFAULT 'TEXT',
section IN VARCHAR2 DEFAULT 'ALL',
level IN VARCHAR2 DEFAULT 'TYPICAL')
RETURN CLOB;
Parameters
Table 29-4 REPORT_ACTIVITY Function Parameters
Parameter | Description |
---|---|
|
Time starting from which the executed automatic indexing operations are considered for the report. If |
|
Time till which the executed automatic indexing operations are considered for the report. If no value is specified, then the current time is considered as the end time. |
|
Format of the report. It can have one of the following values:
The default value is |
|
Sections to include in the report. It can have a combination of the following values:
A combination of these values can be specified using the
|
|
Level of automatic indexing information to include in the report. It can have one of the following values:
|
Return Value
A report of the automatic indexing operations executed during the specified period in a database.
Examples
The following example generates a typical report of the automatic indexing operations executed in the last 24 hours. The report is generated in the text format and contains all the sections (summary details, auto index details, auto index verification details, and error details).
declare report clob := null; begin report := dbms_auto_index.report_activity(); end;
29.2.4 REPORT_LAST_ACTIVITY Function
This function returns a report of the last automatic indexing operation executed in a database.
Syntax
DBMS_AUTO_INDEX.REPORT_LAST_ACTIVITY (
type IN VARCHAR2 DEFAULT 'TEXT',
section IN VARCHAR2 DEFAULT 'ALL',
level IN VARCHAR2 DEFAULT 'TYPICAL')
RETURN CLOB;
Parameters
Table 29-5 REPORT_LAST_ACTIVITY Function Parameters
Parameter | Description |
---|---|
|
Format of the report. It can have one of the following values:
The default value is |
|
Sections to include in the report. It can have a combination of the following values:
A combination of these values can be specified using the
|
|
Level of automatic indexing information to include in the report. It can have one of the following values:
|
Return Value
A report of the last automatic indexing operation executed in a database.
Examples
The following example generates a typical report of the last automatic indexing operation executed in a database. The report is generated in the text format and contains all the sections (summary details, auto index details, auto index verification details, and error details).
declare report clob := null; begin report := dbms_auto_index.report_last_activity(); end;