首页 > 解决方案 > Oracle:范围-范围间隔分区/子分区

问题描述

我需要创建一个范围分区表:

IE

    create table table1(item_id number(22), sys_entry_date timestamp default sysdate)
     partition by range(sys_entry_date) interval(NUMTOYMINTERVAL(1,'YEAR'))
   (partition p01 values less than (to_date('31-DEC-2016','DD-MON-YYYY')));

一些用于演示目的的插入:

---Should lie in the main partition's main subpartition (crnt_part) since the it's part of the latest records received.

insert into table1 values(1, sysdatetime);

---Should lie in the main partition's subpartition of default section (prev_part) since the it's 2 days older
insert into table1 values(1, sysdatetime-3);
insert into table1 values(1, sysdatetime-4);

---Would help us identify the yearly partitions (suggestive)
insert into table1 values(2, sysdatetime-1500);
insert into table1 values(3, sysdatetime-1200);
insert into table1 values(4, sysdatetime-800);
insert into table1 values(1, sysdatetime-400);

我想通过它实现以下目标:

  1. 年度分区;
  2. 年度内,基于 sys_entry_date 的子分区 2.a. 最近 2 天在 crnt_part 2.b 举行。保留在默认分区中,可能在 prev_part

感谢有人可以在这种特定情况下提供帮助。

标签: oracletable-partitioning

解决方案


推荐阅读