How to split a single partition into multiple partitions in 12c
Oracle Database - Enterprise Edition - Version 220.127.116.11 and later - Information in this document applies to any platform. Oracle 12C supports splitting a partition into more than 2 partitions.
You can redistribute the contents of one table partition into multiple partitions with the SPLIT PARTITION clause of the ALTER TABLE statement. When splitting multiple partitions, the segment associated with the current partition is discarded. Each new partition obtains a new segment and inherits all of the unspecified physical attributes from the current source partition.
You can use this new extended split syntax to specify a list of new partition descriptions similar to the create partitioned table SQL statements, instead of using the AT or VALUES clauses. Additionally, the Range or List values clause for the last new partition description is derived based on the high bound of the source partition and the bound values specified for the first (N-1) new partitions resulting from the split.
When splitting a DEFAULT List partition or a MAXVALUE Range partition into multiple partitions, the first (N-1) new partitions are created using the literal value lists or high bound values specified, while the Nth new partition resulting from the split have the DEFAULT value or MAXVALUE. The SPLIT_TABLE_SUBPARTITION clause is extended similarly to allow split of a Range or List sub-partition into N new sub-partitions.
To demonstrate new feature in 12c that makes possible to split an Oracle table partition or subpartition into multiple partitions/subpartitions with one statement.
The first example demonstrates splitting a range partition prod100 into multiple partitions, namely prod25, prod50, prod74, and prod100. Partition prod100 derives the high bound of the original partition prod100.
CREATE TABLE prod_list
PARTITION BY RANGE(prod_id)
PARTITION prod100 VALUES LESS THAN (100),
PARTITION prod200 VALUES LESS THAN (200),
PARTITION prod300 VALUES LESS THAN (300),
PARTITION prodother VALUES LESS THAN (MAXVALUE)
alter table prod_list split partition prod100 into
(partition prod25 values less than (25),
partition prod50 values less than (50),
partition prod75 values less than (75),
Same example using subpartitions, assuming prod100 is a subpartition:
alter table prod_list split subpartition prod100 into
(subpartition prod25 values less than (25),
subpartition prod50 values less than (50),
subpartition prod75 values less than (75),
Here is an example using a date range table range_sales and we split the sales_q1_2012 partition into five partitions corresponding to the quarters of the next year.
In this example, the partition sales_mar_2012 implicitly becomes the high bound of the split partition.
CREATE TABLE range_sales
( prod_id NUMBER(6)
, cust_id NUMBER
, time_id DATE
, quantity_sold NUMBER(3)
, amount_sold NUMBER(10,2)
PARTITION BY RANGE (time_id)
(PARTITION SALES_Q1_2012 VALUES LESS THAN (TO_DATE('01-APR-2012','DD-MON-YYYY')),
PARTITION SALES_Q2_2012 VALUES LESS THAN (TO_DATE('01-JUL-2012','DD-MON-YYYY')),
PARTITION SALES_Q3_2012 VALUES LESS THAN (TO_DATE('01-OCT-2012','DD-MON-YYYY')),
PARTITION SALES_Q4_2012 VALUES LESS THAN (MAXVALUE));
ALTER TABLE range_sales SPLIT PARTITION sales_q1_2012 INTO
(PARTITION sales_jan_2012 values less than (TO_DATE('01-FEB-2012','dd-MON-yyyy')),
PARTITION sales_feb_2012 values less than (TO_DATE('01-MAR-2012','dd-MON-yyyy')),
Same example using subpartitions, assuming sales_q1_2012 is a subpartition.
ALTER TABLE range_sales SPLIT SUBPARTITION sales_q1_2012 INTO
(SUBPARTITION sales_jan_2012 values less than (TO_DATE('01-FEB-2012','dd-MON-yyyy')),
SUBPARTITION sales_feb_2012 values less than (TO_DATE('01-MAR-2012','dd-MON-yyyy')),
To split a Range partition into N partitions, (N-1) values of the partitioning key column must be specified within the range of the partition at which to split the partition. The new non-inclusive upper bound values specified must be in ascending order. The high bound of Nth new partition is assigned the value of the high bound of the partition being split. The names and physical attributes of the N new partitions resulting from the split can be optionally specified.
In this example, the sample table customers partitioned by List, splits the partition sales_east into three partitions: NY, FL, and VA.
ALTER TABLE sales_list SPLIT PARTITION sales_east INTO
(PARTITION NY values ('New York'),
PARTITION FL values ('Florida'),
Same example using subpartitions, assuming sales_east is a subpartition:
ALTER TABLE sales_list SPLIT SUBPARTITION sales_east INTO
(SUBPARTITION NY values ('New York'),
SUBPARTITION FL values ('Florida'),
To split a List partition into N partitions, (N-1) lists of literal values must be specified, each of which defines the first (N-1) partitions into which rows with corresponding partitioning key values are inserted. The remaining rows of the original partition are inserted into the Nth new partition whose value list contains the remaining literal values from the original partition. No two value lists can contain the same partition value. The (N-1) value lists that are specified cannot contain all of the partition values of the current partition because the Nth new partition would be empty. Also, the new (N-1) value lists cannot contain any partition values that do not exist for the current partition.
Split Multiple Partitions restrictions:
You cannot specify this clause for a hash partition.
You cannot specify the parallel_clause for index-organized tables.
If table is an index-organized table, or if a local domain index is defined on table, then you can split the partition into only two new partitions.