新建分区是指在已有的分区表上新增一个分区。本文介绍了新建分区的语法及其示例。
语法说明
创建分区
ALTER TABLE <table_name> ADD PARTITION <partition_definition>;
Where partition_definition is:
{<list_partition> | <range_partition>}
and list_partition is:
PARTITION [<partition_name>]
VALUES (<value>[, <value>]...)
[TABLESPACE <tablespace_name>]
[(<subpartition>, ...)]
and range_partition is:
PARTITION [<partition_name>]
VALUES LESS THAN (<value>[, <value>]...)
[TABLESPACE <tablespace_name>]
[(<subpartition>, ...)]
Where subpartition is:
{<list_subpartition> | <range_subpartition> | <hash_subpartition>}
and list_subpartition is:
SUBPARTITION [<subpartition_name>]
VALUES (<value>[, <value>]...)
[TABLESPACE <tablespace_name>]
and range_subpartition is:
SUBPARTITION [<subpartition_name>]
VALUES LESS THAN (<value>[, <value>]...)
[TABLESPACE <tablespace_name>]
创建子分区
ALTER TABLE <table_name> MODIFY PARTITION <partition_name>
ADD SUBPARTITION <subpartition_definition>;
Where subpartition_definition is:
{<list_subpartition> | <range_subpartition>}
and list_subpartition is:
SUBPARTITION [<subpartition_name>]
VALUES (<value>[, <value>]...)
[TABLESPACE <tablespace_name>]
and range_subpartition is:
SUBPARTITION [<subpartition_name>]
VALUES LESS THAN (<value>[, <value>]...)
[TABLESPACE <tablespace_name>]
示例
新建分区
新建范围分区
ALTER TABLE sales ADD PARTITION q1_2013 VALUES LESS THAN('01-APR-2013');
新建列表分区
ALTER TABLE sales ADD PARTITION east_asia VALUES ('CHINA', 'KOREA');
新建子分区
新建范围子分区
ALTER TABLE sales MODIFY PARTITION europe
ADD SUBPARTITION europe_2013 VALUES LESS THAN('2015-Jan-01');
新建列表子分区
ALTER TABLE sales MODIFY PARTITION second_half_2012
ADD SUBPARTITION east_asia VALUES ('CHINA');
文档内容是否对您有帮助?