Local indexes

Objective Create a local index on a partitioned table.
When you create a local index, it is automatically equipartitioned in the same way as its underlying table. This gives you the advantages of an equipartitioned index without declaring the index partitions when the index is created or when the table partitions are maintained or modified. The following MouseOver illustrates the relationship between a local index and its corresponding table.

Local Indexes In order to define a local partitioned index, you only have to add the keyword LOCAL to the end of the CREATE INDEXstatement, as in CREATE INDEX idxA ON tabA(colA) LOCAL (); The local index will automatically be partitioned in the same way as the underlying table. You can specify which tablespace a local index's partitions will be stored in. Prefixed and non-prefixed A prefixed index includes the columns used to partition the underlying table at the beginning of the column list for the index--the left of the column list. Any local index that does not include these columns is a non-prefixed partitioned index. Both prefixed and non-prefixed local indexes are partitioned on the underlying column(s) used to partition the associated table. For this example, assume that your underlying table contains three columns--colA, colB, and colC. The table is partitioned on colA. A local prefixed index could contain colA and colB, and it would be partitioned on colA. A local non-prefixed index may only contain colB, but it would still be partitioned on colA. Prefixed versus non-prefixed indexes There are advantages to using each type of index. When you have a local index that is prefixed, the Oracle optimizer will automatically know to eliminate both index partitions and table partitions if the partitioning key is a part of theWHERE clause. This matching provides the fastest query execution. If an index is not prefixed, you can specify a different column and still benefit from the improved performance. For instance, you could have a table that is partitioned by month and a non-prefixed local index that is partitioned by account number. Assuming that a query asked for the sales for a particular month for a particular account, Oracle could use the index to quickly locate the account number but would not have to search table partitions that did not contain the correct month. The next lesson explains global partitioned indexes.

Global indexes

If colB is unique. PARTITION VALUES LESS THAN 100. you have to explicitly define the partitions and their boundaries. The next lesson explains how to merge existing partitions for a table or index. Unlike local indexes. You can still have an index that is not prefixed. as in: CREATE INDEX idxB ON tabA(colB) GLOBAL PARTITION BY RANGE (colB) (PARTITION VALUES LESS THAN 10. you have to maintain the connection between the index partitions and the table partitions yourself. A global index has entries that can refer to more than one table partition. The MAXVALUE keyword sets an unlimited upper bound for the last partition in this definition. the syntax for defining a global index is different from defining a local index. just as you do with a table. if a table is partitioned on colA. but it cannot be partitioned. Oracle also does not support unique non-prefixed local indexes where the partitioning columns in the index are not a subset of the partition columns in the associated table. Global indexes .Objective Create a global index on a partitioned table.Quiz Click the Quiz link below to answer a few questions about local and global partitions. a global index is not automatically equipartitioned with its underlying table. When you define a global partitioned index. Prefixed and non-prefixed Oracle does not support global non-prefixed indexes. you would have to declare the index a global partitioned index. you have to specify the partitions in the CREATE INDEX statement.Quiz . Although you could define a global partitioned index with the same partitions and range boundaries as its underlying table. colB can not be unique. You only need to specify that a local index is LOCAL and Oracle does the rest. You can use MAXVALUE for the last partition in either an index or a table. and the local index is partitioned on colB. For a global index. In addition. PARTITION VALUES LESS THAN (MAXVALUE)). Global indexes . Using the example from the previous lesson.

Sign up to vote on this title
UsefulNot useful