编写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 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',
,
,
'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',
,
,
'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') 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
SCOTT A2 P2
SCOTT A2 P3
SCOTT A2 P4
SCOTT A2 P5
SCOTT A2 P6
SCOTT A2 P7
SCOTT A2 P8
SCOTT A2 P9
SCOTT A2 P10
SCOTT A2 P11
SCOTT A2 P12
SCOTT A2 P13
SCOTT A2 P14
SCOTT A2 SYS_P41
SCOTT A2 SYS_P42
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
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
SCOTT A2 P2
SCOTT A2 P3
SCOTT A2 P4
SCOTT A2 P5
SCOTT A2 P6
SCOTT A2 P7
SCOTT A2 P8
SCOTT A2 P9
SCOTT A2 P10
SCOTT A2 P11
SCOTT A2 P12
SCOTT A2 P13
SCOTT A2 P14
SCOTT A2 SYS_P43
SCOTT A2 SYS_P41
SCOTT A2 SYS_P42 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 TO_DATE(' 2019-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_2 TO_DATE(' 2019-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_3 TO_DATE(' 2019-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_4 TO_DATE(' 2019-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_5 TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_6 TO_DATE(' 2019-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_7 TO_DATE(' 2019-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_8 TO_DATE(' 2019-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_9 TO_DATE(' 2019-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_10 TO_DATE(' 2019-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_11 TO_DATE(' 2019-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_13 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_14 TO_DATE(' 2020-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_15 TO_DATE(' 2020-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_MAX MAXVALUE
SCOTT B2 D229 PD229_1 TO_DATE(' 2019-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_2 TO_DATE(' 2019-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_3 TO_DATE(' 2019-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_4 TO_DATE(' 2019-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_5 TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_6 TO_DATE(' 2019-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_7 TO_DATE(' 2019-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_8 TO_DATE(' 2019-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_9 TO_DATE(' 2019-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_10 TO_DATE(' 2019-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_11 TO_DATE(' 2019-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_MAX MAXVALUE
SCOTT B2 D230 PD230_1 TO_DATE(' 2019-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_2 TO_DATE(' 2019-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_3 TO_DATE(' 2019-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_4 TO_DATE(' 2019-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_5 TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_6 TO_DATE(' 2019-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_7 TO_DATE(' 2019-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_8 TO_DATE(' 2019-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_9 TO_DATE(' 2019-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_10 TO_DATE(' 2019-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_11 TO_DATE(' 2019-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D230 PD230_MAX MAXVALUE 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 TO_DATE(' 2019-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_2 TO_DATE(' 2019-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_3 TO_DATE(' 2019-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_4 TO_DATE(' 2019-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_5 TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_6 TO_DATE(' 2019-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_7 TO_DATE(' 2019-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_8 TO_DATE(' 2019-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_9 TO_DATE(' 2019-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_10 TO_DATE(' 2019-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_11 TO_DATE(' 2019-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_13 TO_DATE(' 2020-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_14 TO_DATE(' 2020-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_15 TO_DATE(' 2020-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_16 TO_DATE(' 2020-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D228 PD228_MAX MAXVALUE SCOTT B2 D229 PD229_1 TO_DATE(' 2019-02-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_2 TO_DATE(' 2019-03-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_3 TO_DATE(' 2019-04-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_4 TO_DATE(' 2019-05-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_5 TO_DATE(' 2019-06-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_6 TO_DATE(' 2019-07-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_7 TO_DATE(' 2019-08-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_8 TO_DATE(' 2019-09-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_9 TO_DATE(' 2019-10-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_10 TO_DATE(' 2019-11-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_11 TO_DATE(' 2019-12-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_12 TO_DATE(' 2020-01-01 00:00:00', 'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIA
SCOTT B2 D229 PD229_MAX MAXVALUE
编写SQL查询范围分区类型,MAX分区范围的更多相关文章
- Hibernate应用SQL查询返回实体类型
Hibernate应用SQL查询返回实体类型 Hibernate使用SQL查询返回实体类型 以前,使用SQL查询,结果放在 RS 结果集中,还要去转换影射到Java类中.Hibernate中,可以自动 ...
- Hibernate通过自编写sql查询
public List<InterProductMsg> selectIsHaveProductid(String productId) { String sql="SELECT ...
- 编写sql查询语句思路
编写查询语句思路/* 1.首先确定最终输出结果的列,包括几个方面:A.首先这些列来自于一个 表.还是多个表,如果是多个表则可能用到多表查询的(等值连接.不等值 连接.外连接.自连接):B.这些列是直接 ...
- MySQL表的四种分区类型
MySQL表的四种分区类型 一.什么是表分区 通俗地讲表分区是将一大表,根据条件分割成若干个小表.mysql5.1开始支持数据表分区了. 如:某用户表的记录超过了600万条,那么就可以根据入库日期将表 ...
- mysql表分区(摘自 MySQL表的四种分区类型)
一.什么是表分区通俗地讲表分区是将一大表,根据条件分割成若干个小表.mysql5.1开始支持数据表分区了. 如:某用户表的记录超过了600万条,那么就可以根据入库日期将表分区,也可以根据所在地将表分区 ...
- (1.5)MySQL表的5种分区类型
(1.5)MySQL表的5种分区类型 关键词:mysql表分区 小细节: (1)Null 将会放入最小范围区间 (2)无论哪种类型的分区,要么没有主键.唯一键,要么分区表的主键/唯一键都必须包含 ...
- 如何编写更好的SQL查询:终极指南-第一部分
结构化查询语言(SQL)是数据挖掘分析行业不可或缺的一项技能,总的来说,学习这个技能是比较容易的.对于SQL来说,编写查询语句只是第一步,确保查询语句高效并且适合于你的数据库操作工作,才是最重要的.这 ...
- hive SQL 静态分区和 动态分区
Hive 分区介绍: hive中简单介绍分区表(partition table),含动态分区(dynamic partition)与静态分区(static partition) hive中创建分区表没 ...
- mysql分区表之二:MySQL的表的四种分区类型介绍
一.什么是表分区 通俗地讲表分区是将一大表,根据条件分割成若干个小表.mysql5.1开始支持数据表分区了.如:某用户表的记录超过了600万条,那么就可以根据入库日期将表分区,也可以根据所在地将表分区 ...
随机推荐
- 【codeforces 762B】USB vs. PS/2
time limit per test2 seconds memory limit per test256 megabytes inputstandard input outputstandard o ...
- js基础——流程控制语句
1.if语句 if(条件表达式){ 若条件成立只执行我,下面的分支不执行 }else if(条件表达式){ 语句; }else if(条件表达式){ 语句; }else{ ...
- vue-上传文件
<label for="exampleInputFile">头像</label> <img :src=" imgsrc != '' ? im ...
- linux进程延迟
#include <linux/wait.h> long wait_event_interruptible_timeout(wait_queue_head_t *q, condition, ...
- python写的有声小说爬虫
querybook.py from bs4 import BeautifulSoup from lxml import html import xml import requests import s ...
- H3C创建本地用户
[H3C]Local-user wang //创建本地用户--对应上面scheme的 [H3C-luser-wang]Password cipher 456 ...
- ES6/ES7/ES8新特性
ES6 变量的改变 let const 2. 字符串新增方法 let str = 'react'; str.includes('re') // true str.repeat(3) // reactr ...
- jquery自己写的带左右箭头自动播放幻灯插件,简化
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/ ...
- CF1220
CF1220 A one和zero特的字母分别是'n'和'z' 输出他们的数量即可 #include<cstdio> #include<iostream> #include&l ...
- Redis内存回收机制
为什么需要内存回收? 原因有如下两点: 在 Redis 中,Set 指令可以指定 Key 的过期时间,当过期时间到达以后,Key 就失效了. Redis 是基于内存操作的,所有的数据都是保存在内存中, ...