A domain index can be built to have discrete index partitions that correspond to the partitions of a range-, list-, hash-, or interval-partitioned table. Such an index is called a local domain index, as opposed to a global domain index, which has no index partitions. Local domain index refers to a partitioned index as a whole, not to the partitions that compose a local domain index.
A local domain index is equipartitioned with the underlying table: all keys in a local domain index refer to rows stored in its corresponding table partition; none refer to rows in other partitions.
You provide for using local domain indexes in the indextype, with the CREATE INDEXTYPE statement, as demonstrated in Example 8-12.
CREATE INDEXTYPE TextIndexType FOR Contains (VARCHAR2, VARCHAR2) USING TextIndexMethods WITH LOCAL PARTITION WITH SYSTEM MANAGED STORAGE TABLES;
This statement specifies that the implementation type TextIndexMethods is capable of creating and maintaining local domain indexes.
The CREATE INDEX statement creates and partitions the index, as demonstrated by Example 8-13.
CREATE INDEX [schema.]index ON [schema.]table [t.alias] (indexed_column) INDEXTYPE IS indextype [LOCAL [PARTITION [partition [PARAMETERS ('string')]]] [...] ] [PARALLEL parallel_degree] [PARAMETERS ('string')];
The LOCAL [PARTITION] clause indicates that the index is a local index on a partitioned table. You can specify partition names or allow Oracle to generate them.
The PARALLEL clause specifies that the index partitions are to be created in parallel. The ODCIIndexAlter() routines, which correspond to index partition create, rebuild, or populate, are called in parallel.
In the PARAMETERS clause, specify the parameter string that is passed uninterpreted to the appropriate ODCI indextype routine. The maximum length of the parameter string is 1000 characters.
When you specify this clause at the top level of the syntax, the parameters become the default parameters for the index partitions. If you specify this clause as part of the LOCAL [PARTITION] clause, you override any default parameters with parameters for the individual partition. The LOCAL [PARTITION] clause can specify multiple partitions.
When the domain index is created, Oracle invokes the appropriate ODCI routine. If the routine does not return successfully, the domain index is marked FAILED. The only operations supported on an failed domain index are DROP INDEX and (for non-local indexes) REBUILD INDEX. Example 8-14 creates a local domain index ResumeIndex:
CREATE INDEX ResumeIndex ON MyEmployees(Resume) INDEXTYPE IS TextIndexType LOCAL;
A specified index partition cannot be dropped explicitly. To drop a local index partition, you must drop the entire local domain index:
DROP INDEX ResumeIndex;
Use the ALTER INDEX statement to perform the following operations on a local domain index:
The ALTER INDEXTYPE statement lets you change properties and the implementation type of an indextype without having to drop and re-create the indextype, then rebuild all dependent indexes.
State | Description |
---|---|
IN_PROGRESS |
The index or the index partition is in this state before and during the execution of the ODCIIndex DDL interface routines. The state is generally transitional and temporary. However, if the routine ends prematurely, the index could remain marked IN_PROGRESS. |
FAILED |
If the ODCIIndex interface routine doing DDL operations on the index returns an error, the index or index partition is marked FAILED. |
UNUSABLE |
Same as for regular indexes: An index on a partitioned table is marked UNUSABLE as a result of certain partition maintenance operations. Note that, for partitioned indexes,UNUSABLE is associated only with an index partition, not with the index as a whole. |
VALID |
An index is marked VALID if an object that the index directly or indirectly depends upon is exists and is valid. This property is associated only with an index, never with an index partition. |
INVALID/p> |
An index is marked INVALID if an object that the index directly or indirectly depends upon is dropped or invalidated. This property is associated only with an index, never with an index partition. |
DML operations cannot be performed on the underlying table if an index partition of a local domain index is in any of these states: IN_PROGRESS, FAILED, or UNUSABLE. However, if the index is marked UNUSABLE, and SKIP_UNUSABLE_INDEXES = true, then index maintenance is not performed.
The tables in this section list operations that can be performed on the underlying table of an index and describe the effect, if any, on the index. Table 8-5 lists TABLE operations, while Table 8-6 lists ALTER TABLE operations.
Table Operation | Description |
---|---|
DROP table |
Drops the table. Drops all the indexes and their corresponding partitions |
TRUNCATE |
Truncates the table. Truncates all the indexes and the index partitions |
ALTER TABLE Operation | Description |
---|---|
Modify Partition Unusable local indexes |
Marks the local index partition associated with the table partition as UNUSABLE |
Modify Partition Rebuild Unusable local indexes |
Rebuilds the local index partitions that are marked UNUSABLE and are associated with this table partition |
Add Partition |
Adds a new table partition. Also adds a new local index partition. |
Coalesce Partition |
Applicable to only hash partitioned tables. Drops a base table partition. Also drops the associated local index partition. |
Drop Partition |
Drops a base table partition. Also drops the associated local index partition |
Truncate Partition |
Truncate the table partition. Also truncates the associated local index partition |
Move Partition |
Moves the base table partition to another tablespace. Corresponding local index partitions are marked UNUSABLE. |
Split Partition |
Splits a table partition into two partitions. Corresponding local index partition is also split. If the resulting partitions are non-empty, the index partitions are marked UNUSABLE. |
Merge Partition |
Merges two table partitions into one partition. Corresponding local index partitions should also merge. If the resulting partition contains data, the index partition is marked UNUSABLE. |
Exchange Partition Excluding Indexes |
Exchanges a table partition with a non-partitioned table. Local index partitions and global indexes are marked UNUSABLE. |
Exchange Partition Including Indexes |
Exchanges a table partition with a non-partitioned table. Local index partition is exchanged with global index on the non-partitioned table. Index partitions remain USABLE. |
To support local domain indexes, you must implement the standard ODCIIndex methods, plus two additional methods that are specific to local domain indexes:
SQL*Loader conventional path loads and direct path loads are supported for tables on which domain indexes are defined, with this limitation: The table must be heap-organized.
To do a direct path load on a domain index defined on an IOT or on a LOB column, perform these tasks:
< <Object Dependencies, Drop Semantics, and Validation