I want to partition an existing table in oracle 12 using interval partition and list subpartitions. I have found some information on how to partition subsequently in range, but not using interval partition. I want to tell the database the first partition and which value (date) it has and he will auto-create the rest for all datasets in the table.
ALTER TABLE TEST_TABLE MODIFY
PARTITION BY RANGE(TESTDATE) INTERVAL (NUMTOYMINTERVAL(1, 'MONTH'))
SUBPARTITION BY LIST(COMPANY_NR) (
PARTITION p1 VALUES LESS THAN (TO_DATE('01.01.2018 00:00:00', 'DD.MM.YYYY HH24:MI:SS'))
(
SUBPARTITION P_1 VALUES(1),
SUBPARTITION P_2 VALUES(2)
)
);
Is the auto creation of the partitions with interval possible that way? I cannot find any info anywhere. And if yes, what am I doing wrong here? It says I am missing subpartition keyword.
You have to use SUBPARTITION TEMPLATE like this one:
CREATE TABLE TEST_TABLE (...)
PARTITION BY RANGE (TESTDATE) INTERVAL (NUMTOYMINTERVAL(1, 'MONTH'))
SUBPARTITION BY LIST (COMPANY_NR)
SUBPARTITION TEMPLATE
(
SUBPARTITION P_1 VALUES (1),
SUBPARTITION P_2 VALUES (2)
SUBPARTITION P_others VALUES (DEFAULT)
)
(
PARTITION p1 VALUES LESS THAN (DATE '2018-01-01')
);
You can change subpartition template on existing table, see Modifying a Subpartition Template
However, if you like to change partition then you have to use the DBMS_REDEFINITION package.
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.