create table t(a number,b number,c number,d number)
create index t_a on t(a) 创建普通索引
create index t_b on t(b) global 感觉和上面一样
CREATE INDEX t_c ON t(c) 全局 分区索引
GLOBAL PARTITION BY RANGE(c)
(
PARTITION IDX_P1 values less than (1000),
PARTITION IDX_P2 values less than (2000),
PARTITION IDX_P3 values less than (MAXVALUE)
)
begin
for i in 1..2 loop
insert into t values(i,i,i,i);
end loop;commit;
end;
select * from t where c=1 不用索引因为行数很少
truncate table t
begin
for i in 1..2000 loop
insert into t values(i,i,i,i);
end loop;commit;
end;
select * from t where c=1 用索引,因为行数很多
不考虑删除索引分区的问题,因为删除全局索引的一个分区没有任何意义。
分区表
CREATE TABLE t1(
a NUMBER(5),
b VARCHAR2(30),
c NUMBER(10)
d number)
PARTITION BY RANGE(a)(
PARTITION p1 VALUES LESS THAN(10),
PARTITION p2 VALUES LESS THAN(20)
);
create index t1_a on t1(a) 普通索引
create index t1_b on t1(b) global 感觉和上面一样
CREATE INDEX t1_d ON t1(d) local 本地分区索引
CREATE INDEX t1_c ON t1(c) 全局分区索引
GLOBAL PARTITION BY RANGE(c)
(
PARTITION IDX_P1 values less than (1000),
PARTITION IDX_P2 values less than (2000),
PARTITION IDX_P3 values less than (MAXVALUE)
)