Dears,
I have a table that contains two columns one for year and the other for month. I need to partition this table based on year and month, where year represent the partitions and under that the month represent that sub-partitions. What I need is to make automatic list partitioning by year and then automatic sub-partitioning by month under each year so that each year partition will have 12 months sub-partitions. can this be done using the automatic list for both partitions and sub-partitions??
drop table t10 purge;
CREATE TABLE t10 (
id NUMBER,
description VARCHAR2(50),
year number,
month number,
created_date DATE
);
alter table t10 modify
partition by list (year) automatic
subpartition by list (month) automatic
(partition Y_2015 values(2015))
(subpartition M_01 values (01))
online;
I got this this error msg
ERROR at line 1:
ORA-14179: An unsupported partitioning method was specified in this context.
what is the perfect solution for this situation?
Thanks in advance
Osama
No. Automatic list partitioning is unsupported at the subpartition level.
But I don't see the need for this here. You know there are 12 months in a year!
So you can create a subpartition template, listing out the partitions for each month:
CREATE TABLE t10 (
id NUMBER,
description VARCHAR2(50),
year number,
month number,
created_date DATE
) partition by list (year) automatic
subpartition by list (month)
subpartition template (
subpartition M_01 values (01),
subpartition M_02 values (02),
subpartition M_03 values (03),
subpartition M_04 values (04),
subpartition M_05 values (05),
subpartition M_06 values (06),
subpartition M_07 values (07),
subpartition M_08 values (08),
subpartition M_09 values (09),
subpartition M_10 values (10),
subpartition M_11 values (11),
subpartition M_12 values (12)
) (
partition Y_2015 values(2015)
);
Then when you insert a row that will create a new top-level partition, you'll get all the months too:
insert into t10 values (1, 'test', 2016, 3, sysdate);
select partition_name, subpartition_name, high_value
from user_tab_subpartitions
where table_name = 'T10';
PARTITION_NAME SUBPARTITION_NAME HIGH_VALUE
Y_2015 Y_2015_M_01 01
Y_2015 Y_2015_M_02 02
Y_2015 Y_2015_M_03 03
Y_2015 Y_2015_M_04 04
Y_2015 Y_2015_M_05 05
Y_2015 Y_2015_M_06 06
Y_2015 Y_2015_M_07 07
Y_2015 Y_2015_M_08 08
Y_2015 Y_2015_M_09 09
Y_2015 Y_2015_M_10 10
Y_2015 Y_2015_M_11 11
Y_2015 Y_2015_M_12 12
SYS_P2191 SYS_SUBP2179 01
SYS_P2191 SYS_SUBP2180 02
SYS_P2191 SYS_SUBP2181 03
SYS_P2191 SYS_SUBP2182 04
SYS_P2191 SYS_SUBP2183 05
SYS_P2191 SYS_SUBP2184 06
SYS_P2191 SYS_SUBP2185 07
SYS_P2191 SYS_SUBP2186 08
SYS_P2191 SYS_SUBP2187 09
SYS_P2191 SYS_SUBP2188 10
SYS_P2191 SYS_SUBP2189 11
SYS_P2191 SYS_SUBP2190 12