删除数据库重复记录

删除数据库重复记录,删除id最小的那个

delete minutes as a from minutes as a,
(select *,min(id) from minutes GROUP BY time,cateid,p2pbytes,cdnbytes HAVING count(1)>1) as b
where a.time=b.time and a.cateid = b.cateid and a.p2pbytes=b.p2pbytes and a.cdnbytes=b.cdnbytes and a.id>b.id

向mysql数据库中load数据

mysql -h192.168.0.1 -uroot -prootMydb --local-infile=1 -e "LOAD DATA LOCAL INFILE '/data/dist/minutes' INTO TABLE minutes FIELDS TERMINATED BY '\t' (time,cateid,p2pbytes,cdnbytes)"

你可能感兴趣的:(删除数据库重复记录)