这块要分两种情况进行试验,1.没有maxvalue分区。2.有maxvalue分区。
下面分别试验之:
A.没有maxvalue的range分区表增加分区。
1.创建分区表:
SQL> CREATE TABLE t_range_part (ID NUMBER)
2 PARTITION BY RANGE(ID)
3 (
4 PARTITION t_range_1 VALUES LESS THAN (10),
5 PARTITION t_range_2 VALUES LESS THAN (20),
6 PARTITION t_range_3 VALUES LESS THAN (30)
7 );
Table created
2.查看分区表信息:
SQL> select table_name,partition_name,high_value from dba_tab_partitions where table_name='T_RANGE_PART';
TABLE_NAME PARTITION_NAME HIGH_VALUE
------------------------------ ------------------------------ --------------------------------------------------------------------------------
T_RANGE_PART T_RANGE_1 10
T_RANGE_PART T_RANGE_2 20
T_RANGE_PART T_RANGE_3 30
3.添加分区:
SQL> alter table t_range_part add partition t_range_4 values less than (40);
Table altered
4.再次查看分区表信息:
SQL> select table_name,partition_name,high_value from dba_tab_partitions where table_name='T_RANGE_PART';
TABLE_NAME PARTITION_NAME HIGH_VALUE
------------------------------ ------------------------------ --------------------------------------------------------------------------------
T_RANGE_PART T_RANGE_1 10
T_RANGE_PART T_RANGE_2 20
T_RANGE_PART T_RANGE_3 30
T_RANGE_PART T_RANGE_4 40
由以上结果可以看出,分区添加成功!
B.有maxvalue分区的分区表增加分区。
1.创建分区表:
SQL> CREATE TABLE t_range_part (ID NUMBER)
2 PARTITION BY RANGE(ID)
3 (
4 PARTITION t_range_1 VALUES LESS THAN (10),
5 PARTITION t_range_2 VALUES LESS THAN (20),
6 PARTITION t_range_3 VALUES LESS THAN (30),
7 PARTITION t_range_max VALUES LESS THAN (MAXVALUE)
8 );
Table created
2.查看分区表信息:
SQL> select table_name,partition_name,high_value from dba_tab_partitions where table_name='T_RANGE_PART';
TABLE_NAME PARTITION_NAME HIGH_VALUE
------------------------------ ------------------------------ --------------------------------------------------------------------------------
T_RANGE_PART T_RANGE_1 10
T_RANGE_PART T_RANGE_2 20
T_RANGE_PART T_RANGE_3 30
T_RANGE_PART T_RANGE_MAX MAXVALUE
3.添加分区:
注意,有了maxvalue,就不能直接add partition,而是需要max分区split。下面分别试验:
SQL> alter table t_range_part add partition t_range_4 values less than (40);
alter table t_range_part add partition t_range_4 values less than (40)
ORA-14074: 分区界限必须调整为高于最后一个分区界限
SQL> alter table t_range_part split partition t_range_max at (40) into (partition t_range_4,partition t_range_max);
Table altered
4.查看分区表信息:
SQL> select table_name,partition_name,high_value from dba_tab_partitions where table_name='T_RANGE_PART';
TABLE_NAME PARTITION_NAME HIGH_VALUE
------------------------------ ------------------------------ --------------------------------------------------------------------------------
T_RANGE_PART T_RANGE_1 10
T_RANGE_PART T_RANGE_2 20
T_RANGE_PART T_RANGE_3 30
T_RANGE_PART T_RANGE_4 40
T_RANGE_PART T_RANGE_MAX MAXVALUE
结果看出,添加分区成功。
对于有maxvalue分区的分区表来说,其实切割最后一个分区。
--EOF