DM 支持用 ALTER TABLE EXCHANGE PARTITION 语句将分区数据跟普通表数据进行交换,交换的两张表需要具有相同的结构。仅范围分区和 LIST 分区支持交换分区。进行交换的两张表,如果包含加密列,对应的加密列要求加密信息完全一致。
场景模拟:
1、创建分区表
create table callinfo(
id int,
name varchar2(20))
partition by range(id)(
PARTITION p1 values less than(5),
PARTITION p2 VALUES less than(10),
PARTITION p3 values less than(MAXVALUE));
insert into callinfo values(4,‘lilli’);
insert into callinfo values(6,‘lil’);
insert into callinfo values(5,‘lij’);
insert into callinfo values(8,‘lil’);
commit;
2、查询分区表数据
select * from callinfo PARTITION(p2);
3、创建需要进行数据交换的普通表
create table call_history(id int,name varchar2(20));
4、分区交换
alter table callinfo exchange PARTITION p2 with table call_history;
5、数据校验
查询callinfo表p2分区的数据
查询call_history表数据
6、call_history表插入数据
insert into call_history values(9,‘wwr’);
commit;
select * from call_history;
7、call_info的p2分区插入数据
insert into callinfo values(6,‘lil’);
insert into callinfo values(5,‘lij’);
insert into callinfo values(8,‘lil’);
commit;
select * from callinfo PARTITION(p2);
8、分区交换
alter table callinfo exchange PARTITION p2 with table call_history;
9、数据校验
查询callinfo表p2分区的数据
查询call_history表数据
文章
阅读量
获赞