56,678
社区成员
发帖
与我相关
我的任务
分享
Create Table t2 Like t1;
Alter Table t2 Remove Partitioning;
Alter Table t1 Exchange Partition pmax With t2;
Alter Table t1 Reorganize Partition pmax Into (
Partition p20180601 Values Less Than (20180601000000),
Partition pmax Values Less Than (Maxvalue)
);
-- 接下来如何把 t2 中的数据交换回来?
create table _p(id int primary key)
partition by range(id)(
partition p0 values less than(1),
partition pm values less than maxvalue
);
-- <1 和 >=1 的两个区,可以容纳任意数据
insert into _p values(0),(1),(2),(3);
select * from _p partition(p0);
select * from _p partition(pm);
-- 最后一个区pm 为默认区,觉得数据多了,拆分成 3 个: <1, <2,, >=2
alter table _p reorganize partition pm into(
partition p1 values less than(2),
partition pm values less than maxvalue
);
select * from _p partition(p0);
select * from _p partition(p1);
select * from _p partition(pm);
drop table if exists _p;