1、list 分区只能指定一个字段作为分区建,
2、没有LIST分区全局索引
create index t_pe_i_g on t_pe(f)
GLOBAL PARTITION BY list (f)
(partition pg1 values('A','a') ,
partition pg2 values('B','b'),
partition pg3 default)
ORA-14151: 无效的表分区方法
--------------------------------
3、split :没有hash分区的语法
split :其作用在于当一个分区比较的大的时候可以通过split来进行分割为小的分区,同时LOCAL INDEX也会随着基表的
分割而进行分割其名字也和基表相同并且分割的分区索引会随之失效,但是GLOAL却不行,其会失效,普通索引也会失效。
当然如果分割没有造成数据在partition segment中的移动不会出现失效。也就是说失效与否取决于ROWID是否变化
可以对list和range进行分割
list:
ALTER TABLE sales_by_region
SPLIT PARTITION region_east VALUES ('CT', 'MA', 'MD')
INTO
( PARTITION region_east_1
TABLESPACE tbs2,
PARTITION region_east_2
STORAGE (NEXT 2M PCTINCREASE 25))
PARALLEL 5;
range:
ALTER TABLE t_pe SPLIT PARTITION p1 AT (5)
INTO (PARTITION p1_5 ,
PARTITION p1_10);注意这里的AT是小于并非小于等于
实验:
drop table t_pe;
CREATE TABLE t_pe (i NUMBER, j NUMBER , f varchar2(20),k varchar2(20))
PARTITION BY RANGE(j)
(PARTITION p1 VALUES LESS THAN (10),
PARTITION p2 VALUES LESS THAN (20));
create index t_pe_i_g on t_pe(f)
GLOBAL PARTITION BY range (f)
(partition pg1 values less than('B') ,
partition pg2 values less than ('C'),
partition pg3 values less than(MAXVALUE));
create index t_pe_i_n on t_pe(i);
create index t_pe_i_l on t_pe(j) local;
insert into t_pe
values(2,4,'a','A');
insert into t_pe
values(2,9,'a','A');
insert into t_pe
values(1,15,'b','B');
ALTER TABLE t_pe SPLIT PARTITION p1 AT (5)
INTO (PARTITION p1_5 ,
PARTITION p1_10);
select INDEX_NAME ,STATUS,a.partition_name from dba_ind_partitions a where lower(index_name)='t_pe_i_l';
select INDEX_NAME ,STATUS,a.partition_name from dba_ind_partitions a where lower(index_name)='t_pe_i_g';
select INDEX_NAME ,STATUS from dba_indexes where lower(index_name)='t_pe_i_n';
INDEX_NAME STATUS PARTITION_NAME
------------------------------ -------- ------------------------------
T_PE_I_L UNUSABLE P1_10
T_PE_I_L UNUSABLE P1_5
T_PE_I_L USABLE P2
INDEX_NAME STATUS PARTITION_NAME
------------------------------ -------- ------------------------------
T_PE_I_G UNUSABLE PG1
T_PE_I_G UNUSABLE PG2
T_PE_I_G UNUSABLE PG3
INDEX_NAME STATUS
------------------------------ --------
T_PE_I_N UNUSABLE
我们可以加上 update index来避免这种情况
INDEX_NAME STATUS PARTITION_NAME
------------------------------ -------- ------------------------------
T_PE_I_L USABLE P1_10
T_PE_I_L USABLE P1_5
T_PE_I_L USABLE P2
INDEX_NAME STATUS PARTITION_NAME
------------------------------ -------- ------------------------------
T_PE_I_G USABLE PG1
T_PE_I_G USABLE PG2
T_PE_I_G USABLE PG3
INDEX_NAME STATUS
------------------------------ --------
T_PE_I_N VALID