创建范围分区:
create table range_part_tab (id number,deal_date date,area_code number,contents varchar2(4000))
partition by range(deal_date)
(
partition p1 values less than (TO_DATE('2012-02-01','YYYY-MM-DD')),
partition p2 values less than (TO_DATE('2012-03-01','YYYY-MM-DD')),
partition p3 values less than (TO_DATE('2012-04-01','YYYY-MM-DD')),
partition p4 values less than (TO_DATE('2012-05-01','YYYY-MM-DD')),
partition p5 values less than (TO_DATE('2012-06-01','YYYY-MM-DD')),
partition p6 values less than (TO_DATE('2012-07-01','YYYY-MM-DD')),
partition p7 values less than (TO_DATE('2012-08-01','YYYY-MM-DD')),
partition p8 values less than (TO_DATE('2012-09-01','YYYY-MM-DD')),
partition p9 values less than (TO_DATE('2012-10-01','YYYY-MM-DD')),
partition p10 values less than (TO_DATE('2012-11-01','YYYY-MM-DD')),
partition p11 values less than (TO_DATE('2012-12-01','YYYY-MM-DD')),
partition p12 values less than (TO_DATE('2013-01-01','YYYY-MM-DD')),
partition p_max values less than (maxvalue)
);
创建了分区表后,插入2012年一整年日期随机数,和表示福建地区的591到599的随机数记录,共10万条。
insert into range_part_tab (id,deal_date,area_code,contents)
select rownum,
to_date(to_char(sysdate-365,'j')+TRUNC(DBMS_RANDOM.VALUE(0,365)),'j'),
ceil(dbms_random.value(590,599)),
rpad('*',400,'*')
from dual
connect by rownum<=100000;
1、关键字为partition by range,标志位范围分区
2、values less than是范围分区特定的语法
3、partition1到p_max表示建立的13个分区
4、表示超出的范围记录在这个分区中
5、也可以写在不同的分区表里partition p_max values less than (maxvalue)
阅读(1359) | 评论(0) | 转发(0) |