mysql 删除重复记录,使用临时表的方法:
第二步:清除原表old_table的所有记录
truncate table old_table;
第三步:将临时表new_table的数据记录插入到清空后的原表old_table中
insert into old_table select * from new_table;
第四步:删除临时表
drop table new_table;
第一步:创建临时表new_table(表名可自己取,这里取名new_table,old_table表示需要清除重复记录的表),并将原表的数据写入到临时表中, 使用distinct过滤掉重复的记录。
create temporary table new_table select distinct * from old_table;第二步:清除原表old_table的所有记录
truncate table old_table;
第三步:将临时表new_table的数据记录插入到清空后的原表old_table中
insert into old_table select * from new_table;
第四步:删除临时表
drop table new_table;
本文介绍了一种使用临时表的方法来清除MySQL表中的重复记录。首先创建一个临时表并使用DISTINCT关键字选择原始表中的唯一记录,然后清空原始表,再将临时表中的数据重新导入到原始表中,并最后删除临时表。
1132

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



