表中重复的记录不多,比如,记录总数60000,重复记录也就3000左右。
如何快速删除?注明:此处的记录重复是指部分字段重复,最后一个字段不重复。delete from tableA where (ziduan1,ziduan2,...) not in (select * from (select ziduan1,ziduan2,ziduan3,.. as p from tableA group by ziduan1,ziduan2,...)我用上面的语句删除记录,发现需要花费很多时间,且随着记录总数的增加,花费的时间也在增加,不知道如何快速删除?
如何快速删除?注明:此处的记录重复是指部分字段重复,最后一个字段不重复。delete from tableA where (ziduan1,ziduan2,...) not in (select * from (select ziduan1,ziduan2,ziduan3,.. as p from tableA group by ziduan1,ziduan2,...)我用上面的语句删除记录,发现需要花费很多时间,且随着记录总数的增加,花费的时间也在增加,不知道如何快速删除?
select ziduan1,ziduan2,...,最后一个字段
from tb
group by ziduan1,ziduan2,...drop table tb;
rename table temp to tb;
select * from tt a where not exists(select 1 from tt where a.a=a and a.b=b and a.c=c and a.d<d)