有一个表 有500万条数据需要删除重复,重复的都是10位以内的数字。 都是int类型的使用如以下类似语句,实在太慢,执行了几个小时都没有弄完。
delete t1 from a t1,a t2 where t1.tid=t2.tid and t1.ID>t2.ID;ID tid
1 3241
2 3241
3 545554
4 545554
5 545455需要将tid 中 ,重复的删除。
delete t1 from a t1,a t2 where t1.tid=t2.tid and t1.ID>t2.ID;ID tid
1 3241
2 3241
3 545554
4 545554
5 545455需要将tid 中 ,重复的删除。
select t1.* from a t1,a t2 where t1.tid=t2.tid and t1.ID>t2.ID;
ACMAIN_CHM 大侠 ,给个方法吧。。
select id from table group by id having count(*) > 1
然后再组织sql去删除,这样可以避免了大表的自连接问题。
rename table tt_new to tt;