废话少说,直接讲分区语法。
Oracle表分区分为四种:范围分区,散列分区,列表分区和复合分区。
一:范围分区
就是根据数据库表中某一字段的值的范围来划分分区,例如:
插入实验数据:
下面查询一下全部数据,然后查询各个分区数据,代码一起写:
全部数据如下:
[img]http://dl.iteye.com/upload/attachment/0068/0870/a4446368-930c-3dd4-b9db-284364479226.jpg[/img]
不及格数据如下:
[img]http://dl.iteye.com/upload/attachment/0068/0872/3ed63e0f-770b-3368-a8aa-e19f0b6d9b2d.jpg[/img]
及格数据如下:
[img]http://dl.iteye.com/upload/attachment/0068/0874/7c997ef5-1ae9-37cf-af5a-aaf452850ea2.jpg[/img]
优秀数据如下:
[img]http://dl.iteye.com/upload/attachment/0068/0876/62887263-8fca-3a59-a3c2-8ca4aba752a6.jpg[/img]
[b][color=blue]说明:数据中有空值,Oracle机制会自动将其规划到maxvalue的分区中。 [/color][/b]
[img]http://dl.iteye.com/upload/attachment/0068/0868/0b88d70d-c36e-3b2e-ae0a-28e022f5127f.jpg[/img]
Oracle表分区分为四种:范围分区,散列分区,列表分区和复合分区。
一:范围分区
就是根据数据库表中某一字段的值的范围来划分分区,例如:
create table graderecord
(
sno varchar2(10),
sname varchar2(20),
dormitory varchar2(3),
grade int
)
partition by range(grade)
(
partition bujige values less than(60), --不及格
partition jige values less than(85), --及格
partition youxiu values less than(maxvalue) --优秀
)
插入实验数据:
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(sno,sname,dormitory) values('511606','峰','228');
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);
下面查询一下全部数据,然后查询各个分区数据,代码一起写:
select * from graderecord;
select * from graderecord partition(bujige);
select * from graderecord partition(jige);
select * from graderecord partition(youxiu);
全部数据如下:
[img]http://dl.iteye.com/upload/attachment/0068/0870/a4446368-930c-3dd4-b9db-284364479226.jpg[/img]
不及格数据如下:
[img]http://dl.iteye.com/upload/attachment/0068/0872/3ed63e0f-770b-3368-a8aa-e19f0b6d9b2d.jpg[/img]
及格数据如下:
[img]http://dl.iteye.com/upload/attachment/0068/0874/7c997ef5-1ae9-37cf-af5a-aaf452850ea2.jpg[/img]
优秀数据如下:
[img]http://dl.iteye.com/upload/attachment/0068/0876/62887263-8fca-3a59-a3c2-8ca4aba752a6.jpg[/img]
[b][color=blue]说明:数据中有空值,Oracle机制会自动将其规划到maxvalue的分区中。 [/color][/b]
[img]http://dl.iteye.com/upload/attachment/0068/0868/0b88d70d-c36e-3b2e-ae0a-28e022f5127f.jpg[/img]