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);
(
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);