day11_分区表------子分区的母模板(10g)
create table t_test_subtemplate
(
rec_type varchar2(10),
capture_time date,
uuid number
)
partition by range(capture_time)
subpartition by list(uuid)
subpartition template
(
subpartition sub_10 values(1, 2, 3, 4, 5, 6, 7, 8, 9, 10),
subpartition sub_20 values(11, 12, 13, 14, 15, 16, 17, 18, 19, 20),
subpartition sub_30 values(21, 22, 23, 24, 25, 26, 27, 28, 29, 30),
subpartition sub_40 values(31, 32, 33, 34, 35, 36, 37, 38, 39, 40),
subpartition sub_50 values(41, 42, 43, 44, 45, 46, 47, 48, 49, 50),
subpartition sub_60 values(51, 52, 53, 54, 55, 56, 57, 58, 59, 60)
)
(
partition part_201101 values less than(to_date('20110131', 'YYYYMMDD'))
);
如上,subpartition template会建立一个子分区的模板,接下来添加分区不必指定子分区,oracle会根据模板创建子分区。
执行以下语句查看子分区情况:
select table_name, partition_name, subpartition_name from user_tab_subpartitions;
结果如下:
TABLE_NAME PARTITION_NAME SUBPARTITION_NAME
------------------------------ ------------------------------ ------------------------------
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_10
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_20
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_30
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_40
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_50
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_60
添加分区:
alter table t_test_subtemplate add partition part_201102 values less than(to_date('20110228', 'YYYYMMDD'));
再次查看子分区情况:
TABLE_NAME PARTITION_NAME SUBPARTITION_NAME
------------------------------ ------------------------------ ------------------------------
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_10
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_20
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_30
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_40
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_50
T_TEST_SUBTEMPLATE PART_201101 PART_201101_SUB_60
T_TEST_SUBTEMPLATE PART_201102 PART_201102_SUB_10
T_TEST_SUBTEMPLATE PART_201102 PART_201102_SUB_20
T_TEST_SUBTEMPLATE PART_201102 PART_201102_SUB_30
T_TEST_SUBTEMPLATE PART_201102 PART_201102_SUB_40
T_TEST_SUBTEMPLATE PART_201102 PART_201102_SUB_50
T_TEST_SUBTEMPLATE PART_201102 PART_201102_SUB_60