我们来自五湖四海,不为别的,只因有共同的爱好,为中国互联网发展出一分力!
领航时时彩重庆版

时时彩一星怎么算中奖:Oracle11g下自动创建分区

2014年05月11日23:23 阅读: 33693 次

领航时时彩重庆版 www.9nwl5.cn 标签: Oracle11g下自动创建分区

11g之前,维护分区需要手工。11g之后使用interval来实现自动扩展分区,简化了维护。

根据年: INTERVAL(NUMTOYMINTERVAL(1,'YEAR'))

根据月: INTERVAL(NUMTOYMINTERVAL(1,'MONTH'))

根据天: INTERVAL(NUMTODSINTERVAL(1,'DAY'))

根据时分秒: NUMTODSINTERVAL( n, { 'DAY'|'HOUR'|'MINUTE'|'SECOND'})

下面用按月自动扩展来做个试验:

SQL> create table t_range (id number not null PRIMARY KEY, test_date date)
partition by range (test_date) interval (numtoyMinterval (1,'MONTH'))
(
partition p_2014_01_01 values less than (to_date('2014-01-01', 'yyyy-mm-dd'))
);
--看到只有一个分区
SQL> select partition_name from user_tab_partitions where table_name='T_RANGE';
PARTITION_NAME
------------------------------
P_2014_01_01


SQL> insert /*+append */ into t_range select rownum,
to_date(to_char(sysdate - 140, 'J') +
trunc(dbms_random.value(0, 80)),
'J')
from dual
connect by rownum <= 100000;
SQL> commit;

--可以看到SYS开头的分区是自动扩展的
SQL> select partition_name from user_tab_partitions where table_name='T_RANGE';
PARTITION_NAME
------------------------------
P_2014_01_01
SYS_P21
SYS_P22
SYS_P23

--再看看t_range的表结构

create table T_RANGE
(
ID NUMBER not null,
TEST_DATE DATE
)
partition by range (TEST_DATE)
(
partition P_2014_01_01 values less than (TO_DATE(' 2014-01-01 00:00:00',
'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
partition SYS_P21 values less than (TO_DATE(' 2014-02-01 00:00:00',
'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
partition SYS_P22 values less than (TO_DATE(' 2014-03-01 00:00:00',
'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN')),
partition SYS_P23 values less than (TO_DATE(' 2014-04-01 00:00:00',
'SYYYY-MM-DD HH24:MI:SS', 'NLS_CALENDAR=GREGORIAN'))
);
-- Create/Recreate primary, unique and foreign key constraints
alter table T_RANGE
add primary key (ID);

--如果对分区名不太爽,则可以自己修改一下:

alter table t_range rename partition SYS_P21 to p_2014_02_01;
alter table t_range rename partition SYS_P22 to p_2014_03_01;
alter table t_range rename partition SYS_P23 to p_2014_04_01;

摘自官方文档:

Restrictions on Interval Partitioning The INTERVAL clause is subject to the restrictions listed in "Restrictions on Partitioning in General" and "Restrictions on Range Partitioning". The following additional restrictions apply:

You can specify only one partitioning key column, and it must be of NUMBER, DATE, FLOAT, or TIMESTAMP data type.

This clause is not supported for index-organized tables.

This clause is not supported for tables containing nested table columns or varray columns.

You cannot create a domain index on an interval-partitioned table.

Interval partitioning is not supported at the subpartition level.

Serializable transactions do not work with interval partitioning. Trying to insert data into a partition of an interval partitioned table that does not yet have a segment causes an error.

In the VALUES clause:

You cannot specify MAXVALUE (an infinite upper bound), because doing so would defeat the purpose of the automatic addition of partitions as needed.

You cannot specify NULL values for the partitioning key column.

分享到: 更多
©2019 安全焦点 版权所有.

  • 2018年世界杯防骗宝典!拒绝和骗子一起狂欢! 2019-04-16
  • [微笑]其实很简单就能破这个局:立法禁止通过房地产二次交易获利,炒房就会被杜绝,炒房一旦被杜绝,房价就会受正常供需关系影响波动在合理范围内。 2019-04-16
  • 中国人打仗?被逗了。独生子一代、捧在手里长大的90后00后、站在甲板上飒爽英姿、硝烟战火血肉横飞的场景、会失去行动能力的。这不是耸人听闻。 2019-04-14
  • 乌鲁木齐市水磨沟区开建两座立体停车库 2019-04-14
  • 吕洪蕾:网络信息技术在干部工作中的运用研究 2019-04-04
  • 聚焦中央经济工作会议 2019-03-30
  • 沈杰:在北京打拼的“90后”台湾律师 2019-03-30
  • 法国总统马克龙首次访华 法国居民期待成果 2019-03-25
  • 【新媒体矩阵】长城编小厨 2019-03-25
  • 1949年刚刚进入北平的人民日报校对科夜班工作场面 2019-03-22
  • 江西省“放管服”改革再出实招 2019-03-21
  • 让“毒跑道”绝迹 内蒙古各方联手共同监管校园跑道 2019-03-20
  • 宁夏石嘴山支队隆重举行退伍老兵欢送仪式 2019-03-19
  • 月销过万!赛道疾驰! 吉利帝豪GL竞争力解析 2019-03-19
  • 靠啥为基层留住人才?( 民生视线·引导人才流动 助力均衡发展①) 2019-03-15
  • 486| 748| 370| 15| 274| 955| 977| 444| 742| 762|