oracle range分区表增加分区

前端之家收集整理的这篇文章主要介绍了oracle range分区表增加分区前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。

原文:http://www.jb51.cc/article/p-apdawaco-gn.html

这块要分两种情况进行试验,1.没有maxvalue分区。2.有maxvalue分区。
下面分别试验之:
www.2cto.com
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
www.2cto.com
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,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,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
www.2cto.com
4.查看分区表信息:
sql> select table_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分区的分区表来说,其实切割最后一个分区。

猜你在找的Oracle相关文章