1 概述
索引是否分区
非分区索引
普通索引
分区索引
本地分区索引:Local
本地前缀分区索引:Prefixed,索引列 = 分区列
全局分区索引:Global
不适用:位图索引
本地非前缀分区索引:Nonprefixed,索引列 <> 分区列
2 分区索引
2.1 本地分区索引
create table scott.partition (
p_id number,
p_id2 number,
p_name varchar2(50),
p_date date
) partition by range(p_id)(
partition p1 values less than (20000),
partition p2 values less than (40000),
partition p3 values less than (80000),
partition p4 values less than (100000),
partition p5 values less than (maxvalue)
);
create index scott.partition_local on scott.partition(p_id)
local(partition p1,
partition p2,
partition p3);
create index scott.partition_local on scott.partition(p_id)
local(partition p1,
partition p2,
partition p3,
partition p4,
partition p5);
create index scott.partition_local on scott.partition(p_id)
local;
create index scott.partition_normal on scott.partition(p_name);
create index scott.partition_local2 on scott.partition(p_id2)
local;
2.2 全局分区索引
create index scott.partition_global on scott.partition(p_date)
global partition by range(p_date)
(partition pg1 values less than(to_date('2020-01-01', 'YYYY-MM-DD')),
partition pg2 values less than(to_date('2021-01-01', 'YYYY-MM-DD')),
partition pg3 values less than(to_date('2022-01-01', 'YYYY-MM-DD')),
partition pg4 values less than(to_date('2023-01-01', 'YYYY-MM-DD')),
partition pg5 values less than(maxvalue));
create index scott.partition_global on scott.partition(p_date)
global;
2.3 索引查询
select * from dba_part_indexes;
select * from dba_ind_partitions;
select * from dba_indexes;
3 扩展
3.1 表分区
|