编写SQL查询范围分区类型,MAX分区范围
需求
对于分区表,对于范围分区类型来说,查询MAX分区及对应的分区范围。
==查询分区表对应的最大分区信息 ==排除了自扩展分区(如果是自扩展分区,但是最大的分区不是自扩展的并未排除在外) ==排除了删除的分区表及SYS用户下的,显示范围类型分区表最大分区及分区范围 WITH A AS (SELECT TABLE_OWNER, TABLE_NAME, MAX(PARTITION_POSITION) POSI FROM DBA_TAB_PARTITIONS WHERE TABLE_NAME IN (SELECT DISTINCT TABLE_NAME FROM DBA_PART_TABLES WHERE OWNER NOT LIKE '%SYS%' AND PARTITIONING_TYPE = 'RANGE') GROUP BY TABLE_OWNER, TABLE_NAME), B AS ( SELECT P.TABLE_OWNER, P.TABLE_NAME, PARTITION_NAME, HIGH_VALUE FROM DBA_TAB_PARTITIONS P, A WHERE P.TABLE_OWNER = A.TABLE_OWNER AND P.TABLE_NAME = A.TABLE_NAME AND P.PARTITION_POSITION = A.POSI AND P.TABLE_NAME NOT LIKE 'BIN$%' AND P.INTERVAL!='YES'), Aa AS (SELECT TABLE_OWNER, TABLE_NAME,PARTITION_NAME, MAX(SUBPARTITION_POSITION) POSI FROM DBA_TAB_SUBPARTITIONS WHERE (TABLE_OWNER,TABLE_NAME) IN (SELECT DISTINCT OWNER,TABLE_NAME FROM DBA_PART_TABLES WHERE OWNER NOT LIKE '%SYS%' AND SUBPARTITIONING_TYPE = 'RANGE') GROUP BY TABLE_OWNER,TABLE_NAME,PARTITION_NAME), Bb AS ( SELECT P.TABLE_OWNER, P.TABLE_NAME, P.PARTITION_NAME||' '||P.SUBPARTITION_NAME AS "PARTITION_NAME",HIGH_VALUE FROM DBA_TAB_SUBPARTITIONS P, Aa WHERE P.TABLE_OWNER = Aa.TABLE_OWNER AND P.TABLE_NAME = Aa.TABLE_NAME AND p.PARTITION_NAME=Aa.PARTITION_NAME AND P.SUBPARTITION_POSITION = Aa.POSI AND P.TABLE_NAME NOT LIKE 'BIN$%' AND P.INTERVAL!='YES') select * from B union all select * from Bb; TABLE_OWNE TABLE_NAME PARTITION_NAME HIGH_VALUE ---------- ---------- -------------------- -------------------------------------------------------------------------------- SCOTT A1 P15 TO_DATE(' 2020-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A12 P_MAX MAXVALUE SCOTT A2 SYS_P42 MAXVALUE SCOTT A11 P14 TO_DATE(' 2020-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B1 D228 PD228_13 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B11 D240 PD240_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B1 D229 PD229_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B12 D230 PD230_MAX MAXVALUE SCOTT B2 D230 PD230_MAX MAXVALUE SCOTT B11 D228 PD228_13 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_MAX MAXVALUE SCOTT B2 D229 PD229_MAX MAXVALUE SCOTT B1 D240 PD240_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B11 D243 PD243_2 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B12 D229 PD229_MAX MAXVALUE SCOTT B1 D241 PD241_2 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B11 D229 PD229_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B11 D241 PD241_2 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B11 D242 PD242_2 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B12 D228 PD228_MAX MAXVALUE 20 rows selected. ===使用如下链接,达到排除MAX以及后续可以加条件进行过滤 参考如下链接 http://note.youdao.com/noteshare?id=0d67e2b6ce09f83b72be1f54409ae6bf&sub=3B635C69EEB449A495585F0F79A418B2 http://www.oracleplus.net/arch/281.html 案例:Oracle数据库long查询结果转换为varchar2类型方法的操作步骤 WITH A AS (SELECT TABLE_OWNER, TABLE_NAME, MAX(PARTITION_POSITION) POSI FROM DBA_TAB_PARTITIONS WHERE TABLE_NAME IN (SELECT DISTINCT TABLE_NAME FROM DBA_PART_TABLES WHERE OWNER NOT LIKE '%SYS%' AND PARTITIONING_TYPE = 'RANGE') GROUP BY TABLE_OWNER, TABLE_NAME), B AS ( SELECT P.TABLE_OWNER, P.TABLE_NAME, PARTITION_NAME, HIGH_VALUE, INTERVAL FROM DBA_TAB_PARTITIONS P, A WHERE P.TABLE_OWNER = A.TABLE_OWNER AND P.TABLE_NAME = A.TABLE_NAME AND P.PARTITION_POSITION = A.POSI AND P.TABLE_NAME NOT LIKE 'BIN$%' AND P.INTERVAL!='YES'), C AS ( SELECT * FROM (SELECT b.TABLE_OWNER, b.TABLE_NAME, b.PARTITION_NAME, LONG_HELP.SUBSTR_OF('SELECT HIGH_VALUE FROM DBA_TAB_PARTITIONS WHERE DBA_TAB_PARTITIONS.TABLE_OWNER=:TABLE_OWNER AND TABLE_NAME=:TABLE_NAME AND PARTITION_NAME=:PARTITION_NAME', 1, 4000, 'TABLE_OWNER', DBA_TAB_PARTITIONS.TABLE_OWNER, 'TABLE_NAME', DBA_TAB_PARTITIONS.TABLE_NAME, 'PARTITION_NAME', DBA_TAB_PARTITIONS.PARTITION_NAME) HIGH_VALUE FROM DBA_TAB_PARTITIONS,B WHERE DBA_TAB_PARTITIONS.TABLE_OWNER=B.TABLE_OWNER AND DBA_TAB_PARTITIONS.TABLE_NAME=B.TABLE_NAME AND DBA_TAB_PARTITIONS.PARTITION_NAME=B.PARTITION_NAME ) where high_value not like 'MAXVALUE%'), Aa AS (SELECT TABLE_OWNER, TABLE_NAME,PARTITION_NAME, MAX(SUBPARTITION_POSITION) POSI FROM DBA_TAB_SUBPARTITIONS WHERE (TABLE_OWNER,TABLE_NAME) IN (SELECT DISTINCT OWNER,TABLE_NAME FROM DBA_PART_TABLES WHERE OWNER NOT LIKE '%SYS%' AND SUBPARTITIONING_TYPE = 'RANGE') GROUP BY TABLE_OWNER,TABLE_NAME,PARTITION_NAME), Bb AS ( SELECT P.TABLE_OWNER, P.TABLE_NAME, P.PARTITION_NAME, P.SUBPARTITION_NAME,HIGH_VALUE FROM DBA_TAB_SUBPARTITIONS P, Aa WHERE P.TABLE_OWNER = Aa.TABLE_OWNER AND P.TABLE_NAME = Aa.TABLE_NAME AND p.PARTITION_NAME=Aa.PARTITION_NAME AND P.SUBPARTITION_POSITION = Aa.POSI AND P.TABLE_NAME NOT LIKE 'BIN$%' AND P.INTERVAL!='YES'), Cc as ( SELECT TABLE_OWNER,TABLE_NAME,PARTITION_NAME||' '||SUBPARTITION_NAME AS "PARTITION_NAME",HIGH_VALUE FROM (SELECT Bb.TABLE_OWNER, Bb.TABLE_NAME, Bb.PARTITION_NAME, Bb.SUBPARTITION_NAME, LONG_HELP.SUBSTR_OF('SELECT HIGH_VALUE FROM DBA_TAB_SUBPARTITIONS WHERE TABLE_OWNER=:TABLE_OWNER AND TABLE_NAME=:TABLE_NAME AND PARTITION_NAME=:PARTITION_NAME AND SUBPARTITION_NAME=:SUBPARTITION_NAME', 1, 4000, 'TABLE_OWNER', DBA_TAB_SUBPARTITIONS.TABLE_OWNER, 'TABLE_NAME', DBA_TAB_SUBPARTITIONS.TABLE_NAME, 'PARTITION_NAME', DBA_TAB_SUBPARTITIONS.PARTITION_NAME, 'SUBPARTITION_NAME', DBA_TAB_SUBPARTITIONS.SUBPARTITION_NAME) HIGH_VALUE FROM DBA_TAB_SUBPARTITIONS,Bb WHERE DBA_TAB_SUBPARTITIONS.TABLE_OWNER=Bb.TABLE_OWNER AND DBA_TAB_SUBPARTITIONS.TABLE_NAME=Bb.TABLE_NAME AND DBA_TAB_SUBPARTITIONS.PARTITION_NAME=Bb.PARTITION_NAME AND DBA_TAB_SUBPARTITIONS.SUBPARTITION_NAME=Bb.SUBPARTITION_NAME) where high_value not like 'MAXVALUE%') select * from C union all select * from Cc; TABLE_OWNE TABLE_NAME PARTITION_NAME HIGH_VALUE ---------- ---------- ------------------------------ ------------------------------------------------------------------------------------- SCOTT A1 P15 TO_DATE(' 2020-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') SCOTT A11 P14 TO_DATE(' 2020-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') SCOTT B1 D228 PD228_13 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') SCOTT B1 D229 PD229_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') SCOTT B1 D240 PD240_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') SCOTT B1 D241 PD241_2 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') SCOTT B11 D228 PD228_13 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') SCOTT B11 D229 PD229_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') SCOTT B11 D240 PD240_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') SCOTT B11 D241 PD241_2 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') SCOTT B11 D242 PD242_2 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') SCOTT B11 D243 PD243_2 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN') 12 rows selected.
---测试,验证分区的编号是否是有顺序的,及MAX编号是否对应MAX分区
SQL> select TABLE_OWNER,TABLE_NAME,PARTITION_NAME,PARTITION_POSITION from DBA_TAB_PARTITIONS where table_owner='SCOTT' and TABLE_NAME='A2'; TABLE_OWNE TABLE_NAME PARTITION_NAME PARTITION_POSITION ---------- ------------------------------ -------------------- ------------------ SCOTT A2 P1 1 SCOTT A2 P2 2 SCOTT A2 P3 3 SCOTT A2 P4 4 SCOTT A2 P5 5 SCOTT A2 P6 6 SCOTT A2 P7 7 SCOTT A2 P8 8 SCOTT A2 P9 9 SCOTT A2 P10 10 SCOTT A2 P11 11 SCOTT A2 P12 12 SCOTT A2 P13 13 SCOTT A2 P14 14 SCOTT A2 SYS_P41 15 SCOTT A2 SYS_P42 16 16 rows selected. SQL> select table_owner,table_name,PARTITION_NAME,HIGH_VALUE from DBA_TAB_PARTITIONS where table_owner='SCOTT' and table_name='A2'; TABLE_OWNE TABLE_NAME PARTITION_NAME HIGH_VALUE ---------- ------------------------------ -------------------- ------------------------------------------------------------------------------------------ SCOTT A2 P1 TO_DATE(' 2019-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P10 TO_DATE(' 2019-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P11 TO_DATE(' 2019-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P13 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P14 TO_DATE(' 2020-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P2 TO_DATE(' 2019-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P3 TO_DATE(' 2019-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P4 TO_DATE(' 2019-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P5 TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P6 TO_DATE(' 2019-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P7 TO_DATE(' 2019-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P8 TO_DATE(' 2019-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 P9 TO_DATE(' 2019-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 SYS_P41 TO_DATE(' 2020-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT A2 SYS_P42 MAXVALUE 16 rows selected. SQL>alter table a2 split partition SYS_P41 at (to_date('2020-03-15','yyyy-mm-dd')) into (partition SYS_P43,partition SYS_P41); SQL> select TABLE_OWNER,TABLE_NAME,PARTITION_NAME,PARTITION_POSITION from DBA_TAB_PARTITIONS where table_owner='SCOTT' and TABLE_NAME='A2'; TABLE_OWNE TABLE_NAME PARTITION_NAME PARTITION_POSITION ---------- ------------------------------ -------------------- ------------------ SCOTT A2 P1 1 SCOTT A2 P2 2 SCOTT A2 P3 3 SCOTT A2 P4 4 SCOTT A2 P5 5 SCOTT A2 P6 6 SCOTT A2 P7 7 SCOTT A2 P8 8 SCOTT A2 P9 9 SCOTT A2 P10 10 SCOTT A2 P11 11 SCOTT A2 P12 12 SCOTT A2 P13 13 SCOTT A2 P14 14 SCOTT A2 SYS_P43 15 SCOTT A2 SYS_P41 16 SCOTT A2 SYS_P42 17 17 rows selected. 也就是说,Oracle会根据分区范围调整PARTITION_POSITION 值,因此查询范围最大的分区,可以使用PARTITION_POSITION MAX对应得分区名称 SQL> select TABLE_OWNER,TABLE_NAME,PARTITION_NAME,SUBPARTITION_NAME,SUBPARTITION_POSITION,HIGH_VALUE from DBA_TAB_SUBPARTITIONS WHERE TABLE_OWNER ='SCOTT' and table_name='B2'; TABLE_OWNE TABLE_NAME PARTITION_ SUBPARTITION_NAME SUBPARTITION_POSITION HIGH_VALUE ---------- ---------- ---------- -------------------- --------------------- ------------------------------------------------------------------------------------- SCOTT B2 D228 PD228_1 1 TO_DATE(' 2019-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_2 2 TO_DATE(' 2019-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_3 3 TO_DATE(' 2019-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_4 4 TO_DATE(' 2019-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_5 5 TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_6 6 TO_DATE(' 2019-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_7 7 TO_DATE(' 2019-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_8 8 TO_DATE(' 2019-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_9 9 TO_DATE(' 2019-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_10 10 TO_DATE(' 2019-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_11 11 TO_DATE(' 2019-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_12 12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_13 13 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_14 14 TO_DATE(' 2020-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_15 15 TO_DATE(' 2020-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_MAX 16 MAXVALUE SCOTT B2 D229 PD229_1 1 TO_DATE(' 2019-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_2 2 TO_DATE(' 2019-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_3 3 TO_DATE(' 2019-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_4 4 TO_DATE(' 2019-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_5 5 TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_6 6 TO_DATE(' 2019-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_7 7 TO_DATE(' 2019-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_8 8 TO_DATE(' 2019-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_9 9 TO_DATE(' 2019-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_10 10 TO_DATE(' 2019-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_11 11 TO_DATE(' 2019-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_12 12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_MAX 13 MAXVALUE SCOTT B2 D230 PD230_1 1 TO_DATE(' 2019-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_2 2 TO_DATE(' 2019-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_3 3 TO_DATE(' 2019-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_4 4 TO_DATE(' 2019-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_5 5 TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_6 6 TO_DATE(' 2019-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_7 7 TO_DATE(' 2019-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_8 8 TO_DATE(' 2019-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_9 9 TO_DATE(' 2019-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_10 10 TO_DATE(' 2019-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_11 11 TO_DATE(' 2019-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_12 12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D230 PD230_MAX 13 MAXVALUE 42 rows selected. SQL>alter table scott.b2 split subpartition PD228_MAX at (to_date('2020-05-01','yyyy-mm-dd')) into ( subpartition PD228_16, subpartition PD228_MAX ) update indexes; select TABLE_OWNER,TABLE_NAME,PARTITION_NAME,SUBPARTITION_NAME,SUBPARTITION_POSITION,HIGH_VALUE from DBA_TAB_SUBPARTITIONS WHERE TABLE_OWNER ='SCOTT' and table_name='B2'; TABLE_OWNE TABLE_NAME PARTITION_ SUBPARTITION_NAME SUBPARTITION_POSITION HIGH_VALUE ---------- ---------- ---------- -------------------- --------------------- ------------------------------------------------------------------------------------- SCOTT B2 D228 PD228_1 1 TO_DATE(' 2019-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_2 2 TO_DATE(' 2019-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_3 3 TO_DATE(' 2019-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_4 4 TO_DATE(' 2019-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_5 5 TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_6 6 TO_DATE(' 2019-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_7 7 TO_DATE(' 2019-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_8 8 TO_DATE(' 2019-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_9 9 TO_DATE(' 2019-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_10 10 TO_DATE(' 2019-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_11 11 TO_DATE(' 2019-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_12 12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_13 13 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_14 14 TO_DATE(' 2020-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_15 15 TO_DATE(' 2020-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_16 16 TO_DATE(' 2020-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D228 PD228_MAX 17 MAXVALUE SCOTT B2 D229 PD229_1 1 TO_DATE(' 2019-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_2 2 TO_DATE(' 2019-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_3 3 TO_DATE(' 2019-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_4 4 TO_DATE(' 2019-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_5 5 TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_6 6 TO_DATE(' 2019-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_7 7 TO_DATE(' 2019-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_8 8 TO_DATE(' 2019-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_9 9 TO_DATE(' 2019-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_10 10 TO_DATE(' 2019-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_11 11 TO_DATE(' 2019-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_12 12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA SCOTT B2 D229 PD229_MAX 13 MAXVALUE