

分区索引分为本地(local index)索引和全局索引(global index)。
In a local partitioned index, the index is
partitioned on the same columns, with the same number of partitions and
the same partition bounds as its table. Each index partition is
associated with exactly one partition of the underlying table, so that
all keys in an index partition refer only to rows stored in a single
table partition. In this way, the database automatically synchronizes
index partitions with their associated table partitions, making each
table-index pair independent.
Local partitioned indexes are common in data warehousing environments. Local indexes offer the following advantages:
Availability is increased because actions that make data invalid or unavailable in a partition affect this partition only.
Partition maintenance is simplified. When moving a table partition,
or when data ages out of a partition, only the associated local index
partition must be rebuilt or maintained. In a global index, all index
partitions must be rebuilt or maintained.
If point-in-time recovery of a partition occurs, then the indexes can be recovered to the recovery time (see "Data File Recovery"). The entire index does not need to be rebuilt.
shows the creation statement for the partitioned hash_sales table, using the prod_id column as partition key. creates a local partitioned index on the time_id column of the hash_sales table.
Example 4-5 Local Partitioned Index
In , the hash_products table has two partitions, so hash_sales_idx has two partitions. Each index partition is associated with a different table partition. Index partition SYS_P38 indexes rows in table partition SYS_P33, whereas index partition SYS_P39 indexes rows in table partition SYS_P34.
A global partitioned index is a B-tree index that is partitioned independently of the underlying
table on which it is created. A single index partition can point to any
or all table partitions, whereas in a locally partitioned index, a
one-to-one parity exists between index partitions and table partitions.
In general, global indexes are useful for OLTP applications, where
rapid access, data integrity, and availability are important. In an OLTP
system, a table may be partitioned by one key, for example, the employees.department_id column, but an application may need to access the data with many different keys, for example, by employee_id or job_id. Global indexes can be useful in this scenario.
You can partition a global index by range or by hash. If partitioned
by range, then the database partitions the global index on the ranges of
values from the table columns you specify in the column list. If
partitioned by hash, then the database assigns rows to the partitions
using a hash function on values in the partitioning key columns.
As an illustration, suppose that you create a global partitioned index on the time_range_sales table from . In this table, rows for sales from 1998 are stored in one partition, rows for sales from 1999 are in another, and so on. creates a global index partitioned by range on the channel_id column.
Example 4-6 Global Partitioned Index
As shown in , a global index partition can contain entries that point to multiple table partitions. Index partition p1 points to the rows with a channel_id of 2, index partition p2 points to the rows with a channel_id of 3, and index partition p3 points to the rows with a channel_id of 4 or 9.
--------------->>官方指南:
Local Partitioned Indexes
CREATE INDEX hash_sales_idx ON hash_sales(time_id) LOCAL;

------------------>>注意区别差异:
Global Partitioned Indexes
CREATE INDEX time_channel_sales_idx ON time_range_sales (channel_id)
GLOBAL PARTITION BY RANGE (channel_id)
(PARTITION p1 VALUES LESS THAN (3),
PARTITION p2 VALUES LESS THAN (4),
PARTITION p3 VALUES LESS THAN (MAXVALUE));
其中本地索引又可以分为有前缀(prefix)的索引和无前缀(nonprefix)的索引。而全局索引目前只支持有前缀的索引。B树索引和位图索引都可以分区,但是HASH索引不可以被分区。位图索引必须是本地索引。
一:本地索引:创建了一个分区表后,如果需要在表上面创建索引,并且索引的分区机制和表的分区机制一样,那么这样的索引就叫做本地分区索引。本地索引是由ORACLE自动管理的,它分为有前缀的本地索引和无前缀的本地索引。什么叫有前缀的本地索引?有前缀的本地索引就是包含了分区键,并且将其作为引导列的索引。什么叫无前缀的本地索引?无前缀的本地索引就是没有将分区键的前导列作为索引的前导列的索引
二:全局索引:与本地分区索引不同的是,全局分区索引的分区机制与表的分区机制不一样。全局分区索引全局分区索引只能是B树索引,到目前为止(10gR2),oracle只支持有前缀的全局索引。另外oracle不会自动的维护全局分区索引,当我们在对表的分区做修改之后,如果执行修改的语句不加上update global indexes的话,那么索引将不可用;


来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/29119536/viewspace-1145136/ ,如需转载,请注明出处,否则将追究法律责任。