分区索引实例


--1、建分区表
CREATE TABLE P_TAB(
C1 INT,
C2 VARCHAR2(16),
C3 VARCHAR2(64),
C4 INT ,
CONSTRAINT PK_PT PRIMARY KEY (C1)
)
PARTITION BY RANGE(C1)(
PARTITION P1 VALUES LESS THAN (10000000),
PARTITION P2 VALUES LESS THAN (20000000),
PARTITION P3 VALUES LESS THAN (30000000),
PARTITION P4 VALUES LESS THAN (MAXVALUE)
);
--2、建全局分区索引
CREATE INDEX IDX_PT_C4 ON P_TAB(C4) GLOBAL PARTITION BY RANGE(C4)
(
PARTITION IP1 VALUES LESS THAN(10000),
PARTITION IP2 VALUES LESS THAN(20000),
PARTITION IP3 VALUES LESS THAN(MAXVALUE)
);
--3、建本地分区索引
CREATE INDEX IDX_PT_C2 ON P_TAB(C2) LOCAL (PARTITION P1,PARTITION P2,PARTITION P3,PARTITION P4);
--4、建全局分区索引(与分区表分区规则相同的列上)
CREATE INDEX IDX_PT_C1
ON P_TAB(C1)
GLOBAL PARTITION BY RANGE (C1)
(
PARTITION IP01 VALUES LESS THAN (10000000),
PARTITION IP02 VALUES LESS THAN (20000000),
PARTITION IP03 VALUES LESS THAN (30000000),
PARTITION IP04 VALUES LESS THAN (MAXVALUE)
);
--5、分区索引数据字典查看
SELECT * FROM USER_IND_PARTITIONS;
SELECT * FROM USER_PART_INDEXES;

你可能感兴趣的:(索引)