当前位置:Gxlcms > 数据库问题 > Oracle之分区表

Oracle之分区表

时间:2021-07-01 10:21:17 帮助过:3人阅读

CREATE TABLE table_name
( 
xx NUMBER(16,0) NOT NULL ENABLE, 
tiems date
PRIMARY KEY ( XH )
)

partition by range (tiems)
subpartition by range (tiems)
(
partition P1 values less than (TO_DATE(‘2016-12-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘))
(
SUBPARTITION P1SUB1 VALUES LESS THAN(TO_DATE(‘2016-1-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P1SUB2 VALUES LESS THAN(TO_DATE(‘2016-2-28 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P1SUB3 VALUES LESS THAN(TO_DATE(‘2016-3-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P1SUB4 VALUES LESS THAN(TO_DATE(‘2016-4-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)) ,
SUBPARTITION P1SUB5 VALUES LESS THAN(TO_DATE(‘2016-5-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P1SUB6 VALUES LESS THAN(TO_DATE(‘2016-6-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P1SUB7 VALUES LESS THAN(TO_DATE(‘2016-7-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P1SUB8 VALUES LESS THAN(TO_DATE(‘2016-8-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P1SUB9 VALUES LESS THAN(TO_DATE(‘2016-9-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P1SUB10 VALUES LESS THAN(TO_DATE(‘2016-10-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P1SUB11 VALUES LESS THAN(TO_DATE(‘2016-11-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P1SUB12 VALUES LESS THAN(TO_DATE(‘2016-12-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘))
),
partition P2 values less than (TO_DATE(‘2017-12-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘))
(
SUBPARTITION P2SUB1 VALUES LESS THAN(TO_DATE(‘2017-1-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P2SUB2 VALUES LESS THAN(TO_DATE(‘2017-2-28 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P2SUB3 VALUES LESS THAN(TO_DATE(‘2017-3-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P2SUB4 VALUES LESS THAN(TO_DATE(‘2017-4-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)) ,
SUBPARTITION P2SUB5 VALUES LESS THAN(TO_DATE(‘2017-5-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P2SUB6 VALUES LESS THAN(TO_DATE(‘2017-6-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P2SUB7 VALUES LESS THAN(TO_DATE(‘2017-7-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P2SUB8 VALUES LESS THAN(TO_DATE(‘2017-8-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P2SUB9 VALUES LESS THAN(TO_DATE(‘2017-9-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P2SUB10 VALUES LESS THAN(TO_DATE(‘2017-10-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P2SUB11 VALUES LESS THAN(TO_DATE(‘2017-11-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P2SUB12 VALUES LESS THAN(TO_DATE(‘2017-12-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘))
),
partition P3 values less than (TO_DATE(‘2018-12-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘))
(
SUBPARTITION P3SUB1 VALUES LESS THAN(TO_DATE(‘2018-1-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P3SUB2 VALUES LESS THAN(TO_DATE(‘2018-2-28 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P3SUB3 VALUES LESS THAN(TO_DATE(‘2018-3-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P3SUB4 VALUES LESS THAN(TO_DATE(‘2018-4-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)) ,
SUBPARTITION P3SUB5 VALUES LESS THAN(TO_DATE(‘2018-5-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P3SUB6 VALUES LESS THAN(TO_DATE(‘2018-6-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P3SUB7 VALUES LESS THAN(TO_DATE(‘2018-7-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P3SUB8 VALUES LESS THAN(TO_DATE(‘2018-8-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P3SUB9 VALUES LESS THAN(TO_DATE(‘2018-9-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P3SUB10 VALUES LESS THAN(TO_DATE(‘2018-10-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P3SUB11 VALUES LESS THAN(TO_DATE(‘2018-11-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P3SUB12 VALUES LESS THAN(TO_DATE(‘2018-12-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘))
),
partition P4 values less than (TO_DATE(‘2018-12-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘))
(
SUBPARTITION P4SUB1 VALUES LESS THAN(TO_DATE(‘2019-1-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P4SUB2 VALUES LESS THAN(TO_DATE(‘2019-2-28 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P4SUB3 VALUES LESS THAN(TO_DATE(‘2019-3-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P4SUB4 VALUES LESS THAN(TO_DATE(‘2019-4-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)) ,
SUBPARTITION P4SUB5 VALUES LESS THAN(TO_DATE(‘2019-5-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P4SUB6 VALUES LESS THAN(TO_DATE(‘2019-6-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P4SUB7 VALUES LESS THAN(TO_DATE(‘2019-7-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P4SUB8 VALUES LESS THAN(TO_DATE(‘2019-8-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P4SUB9 VALUES LESS THAN(TO_DATE(‘2019-9-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P4SUB10 VALUES LESS THAN(TO_DATE(‘2019-10-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P4SUB11 VALUES LESS THAN(TO_DATE(‘2019-11-30 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘)),
SUBPARTITION P4SUB12 VALUES LESS THAN(TO_DATE(‘2019-12-31 00:00:00‘, ‘yyyy-mm-dd hh24:mi:ss‘))
)
)

  创建分区表,并且为其创建分区和子分区

Oracle之分区表

标签:highlight   ora   value   not   oracle   table   key   oracl   primary   

人气教程排行