删除mysql重复行

来源:互联网 发布:随便软件 编辑:程序博客网 时间:2024/05/18 14:22
create temporary table 临时表名 select distinct * from 操作的表名; 
--去掉重复后复制到临时表 

truncate table 操作的表名; 
--删除原表中所有记录 

insert into 操作的表名 select * from 临时表名; 
--把临时表的内容导入原表 

drop table 临时表名; 
--删除临时表 

eg: 
create temporary table newtable select distinct * from oldtable;
 truncate oldtable haha;
 insert into oldertable select * from newtable; 
drop table newtable;
原创粉丝点击