Oracle 表分区

create table tb1
(
  iD int,
  tb_name varchar2(10),
  tb_date date,
  constraint pk primary key(id)
  using index tablespace tbs_1
)
partition by range(tb_date)
(
  partition part1 values less than(to_date('2013-1-1','YYYY-MM-DD')) tablespace tbs_2
  partition part2 values less than(maxvalue) tablespace tbs_3
);


create table tb2
(
  iD int,
  tb_area varchar2(10),
  tb_date date
)
partition by list(tb_area)
(
  partition part1 values('北京') tablespace tbs_1,
  partition part2 values('上海') tablespace tbs_2 
); 


drop table tb2;


insert into tb2
select 1,'北京',to_date('2013-6-1','YYYY-MM-DD')
from dual
union all
select 2,'上海',to_date('2013-12-1','YYYY-MM-DD') 
from dual
union all
select 3,'北京',to_date('2013-2-21','YYYY-MM-DD') 
from dual
union all
select 4,'北京',to_date('2013-9-1','YYYY-MM-DD') 
from dual;


select * from tb2;
select * from tb2 partition(part1);
select * from tb2 partition(part2);

组合分区:
create table graderecord
(   
  sno varchar2(10),   
  sname varchar2(20),   
  dormitory varchar2(3),   
  grade int  
)   
partition by range(grade)   
subpartition by hash(sno,sname)   
(   
  partition part1 values less than(75)   
            (   
               subpartition spart1 tablespace tbs_1,subpartition spart2 tablespace tbs_2
            ),
  partition part2 values less than(maxvalue)   
            (   
               subpartition spart3 tablespace tbs_1,subpartition spart4 tablespace tbs_2
            )
);  


drop table graderecord;




insert into graderecord values('511601','魁','229',92);   
insert into graderecord values('511602','凯','229',62);   
insert into graderecord values('511603','东','229',26);   
insert into graderecord values('511604','亮','228',77);   
insert into graderecord values('511605','敬','228',47);   
insert into graderecord values('511607','明','240',90);   
insert into graderecord values('511608','楠','240',100);   
insert into graderecord values('511609','涛','240',67);   
insert into graderecord values('511610','博','240',75);   
insert into graderecord values('511611','铮','240',60);   
insert into graderecord values('511612','狸','244',72);   
insert into graderecord values('511613','杰','244',88);   
insert into graderecord values('511614','萎','244',19);   
insert into graderecord values('511615','猥','244',65);   
insert into graderecord values('511616','丹','244',59);   
insert into graderecord values('511617','靳','244',95);  




select * from graderecord partition(part1);
select * from graderecord partition(part2);
select * from graderecord subpartition(spart1);
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值