管理分区表
增加分区
语法
alter table ….add partition
1为范围分区表增加分区
创建分区的语句
create table student_range(
sno varchar2(10) ,
sname varchar2(20),
sage number(2),
score number(3)
)partition by range(score)--范围分区表
(
partition part1 values less than(60) tablespace myspace,
partition part2 values less than(80) tablespace myspace,
partition part3 values less than(100) tablespace users
);
在最后一个分区之后增加分区
alter table student_range
add partition part4 values less than(120) tablespace myspace;
在第一个分区(第N个分区)之前增加分区
将分区part1分割为小于30的part5,大于30小于60的part6.
2为散列分区表增加分区
使用alter table add partition就可以,oracle会自动的在已有分区和新建分区进行容量均衡
创建分区的语句
create table student_hash(
sno varchar2(10) ,
sname varchar2(20),
sage number(2),
score number(2)
)partition by hash(sno)--散列分区表
(
partition part1 tablespace myspace,
partition part2 tablespace users
);
alter table student_hash
add partition part3 tablespace myspace;
3为列表分区表增加分区
alter table student_list
add partition part3 values(‘妖’) tablespace myspace;
查看当前用户的表和表分区信息
SELECT table_name,partition_name FROM user_tab_partitions order by table_name;
合并分区
语法
alter table …merge partition
案例
将表student_range的分区part5,part6合并为part1
alter table student_range merge partitions part5,part6 into partition part1;
删除分区
语法
alter table …drop partition
案例
将表student_range的分区part4删除
alter table student_range drop partition part4;