首页 > 代码库 > 创建分区表

创建分区表

--分区表,范围分区create table achievement(id number primary key,name varchar2(10),subject varchar2(10),score number)partition by range(score)( partition part1 values less than(60) tablespace users, partition part2 values less than(80) tablespace users, partition part3 values less than(maxvalue) tablespace users)insert into achievement values(3,张天,Java,null);select * from achievement select * from achievement partition(part3);--全并分区alter table achievement merge partitions part2,part3 into partition part4select * from achievement partition(part4);--删除分区alter table achievement drop partition part4如果没有使用maxvalue 值,则可以给范围分区表增分区alter table achievement add partition part5 values less than(120);当新增加的分区取值没有超过现在分区的最大值,系统会提示出错误--建立局部分区索引,各个分区索引之间是独立的create index achievement_index on achievement (name) local(partition index1 tablespace users,partition index2 tablespace users,partition index3 tablespace users)--建立全局分区索引,各个分区索引之间不是独立的,分区索引和分区表之间也不是简单的一对一关系create index achievement_global_index on achievement (score) global partition by range(score)(partition part1 values less than(60) tablespace users,partition part2 values less than(80) tablespace users,partition part3 values less than(maxvalue) tablespace users,)

 

创建分区表