1.创建表分区
根据成绩建立不同 的分区
create table student(
studentid integer not null,
studentname varchar2(20),
Score integer
)
Partition by range(Score)
(
Partition p1 values less than(60),
Partition p2 values less than(70),
Partition p3 values less than(80),
Partition p4 values less than(maxvalue)
);
向表中插入数据就可开始查询了
2.查看分区
select * from student partition(p1);
3.查看那些表有分区,以及分区的位置、范围
select table_name,partition_name,patition_position,high_value from user_tab_partitions;
4.添加分区
alter table student add partition p5 values less than(50);
5.合并分区
alter table student merge partitions p3,p4 into partition p6;
6.删除分区
alter table student drop partition p5;
本文介绍如何使用SQL语句创建表分区、查看分区信息、添加、合并及删除分区等操作,适用于需要对大量数据进行高效管理和查询的场景。
7780

被折叠的 条评论
为什么被折叠?



