编写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万条,那么就可以根据入库日期将表分区,也可以根据所在地将表分区 ...
随机推荐
- [转载] linux find 命令
转载自 http://www.jb51.net/os/RedHat/1307.html Linux下find命令在目录结构中搜索文件,并执行指定的操作. Linux下find命令提供了相当多的查找条件 ...
- 彻底解决tensorflow:ImportError: Could not find 'cudart64_90.dll' tensorflow安装
今天装tensorflow-gpu出现了很多问题 1.pip install tensorflow-gpu下载过慢 解决办法可查看 Python机器学习常用模块 2.安装完tensorflow以后,运 ...
- Python--day61--安装Django,Django项目的启动和设置运行端口和关闭运行端口
0,安装Django 1,Django项目的启动 2,设置运行端口和关闭运行端口
- H3C 静态路由配置
- git把某个文件去除版本控制
谢谢@jessicway 同学的提醒.我之前没考虑只需要删除服务器上已提交的文件,但是本地不想删除的情况. 我们先看看 git rm 命令的说明 可以看到其实加上 --cached 参数就可以实现只去 ...
- UVa 1635 - Irrelevant Elements-[分解质因数]
Young cryptoanalyst Georgie is investigating different schemes of generating random integer numbers ...
- H3C命令调试debugging--用户视图
<H3C>terminal debugging //使用debugging必须使用的命令--打开调试信 息的屏幕输出开关 <H3C>display debugging ...
- <QluOJ2018NewCode>计算几何(寄蒜几盒)
题目描述 现在有一个圆圈,圆圈上有若干个点,请判断能否在若干个点中选择三个点两两相连组成一个等边三角形? 这若干个点在圆圈上按顺时针顺序分布. 如果可以的话输出"Yes"(不含引号 ...
- dotnet 使用 MessagePack 序列化对象
和很多序列化库一样,可以通过 MessagePack 序列化和反序列化,和 json 相比这个库提供了二进制的序列化,序列化之后的内容长度比 json 小很多 这个库能序列的内容不多,大多数时候建议使 ...
- VisualStudio 断点调试详解
本文详细告诉大家 VisualStudio 断点调试的功能和使用方法,本文使用的是最新 VisualStudio2019 的功能,也许在你看到这篇博客的时候这个版本已经过时 本文将会按照从简单到复杂, ...