建两个临时表备用,复制主表格式
create table pre_common_member_temp like pre_common_member;
create table pre_common_member_temp2 like pre_common_member;
将主表数据插入临表一
insert into pre_common_member_temp select * from pre_common_member;
备份存档表
create table pre_common_member_archive_bak like pre_common_member_archive;
insert into pre_common_member_archive_bak select * from pre_common_member_archive;
将存档表数据插入临表一
insert into pre_common_member_temp select * from pre_common_member_archive;
将临表一的数据去重复排序插入临表二
insert into pre_common_member_temp2 select * from pre_common_member_temp order by uid;
主表改成bak备份,临表二改成主表名,清空存档表的数据
ALTER TABLE pre_common_member RENAME TO pre_common_member_bak;
ALTER TABLE pre_common_member_temp2 RENAME TO pre_common_member;
TRUNCATE TABLE `pre_common_member_archive`;