参考:
http://stackoverflow.com/questions/3311903/remove-duplicate-rows-in-mysql
http://database.51cto.com/art/201011/235159.htm
添加多字段唯一索引,会自动删除重复数据,并不允许插入重复数据。
查询多字段重复数据
select * from plan_device a
where (a.sourceID,a.platformID, a.sourceType) in (select sourceID,platformID,sourceType from plan_device group by sourceID,platformID,sourceType having count(*) > 1)
执行时间很长。
添加不重复的索引
ALTER IGNORE TABLE plan_device ADD UNIQUE INDEX UNIQUE_KEY (`sourceID`, `platformID`, `sourceType`);
--
-- 2014-9-19
--
http://stackoverflow.com/questions/3311903/remove-duplicate-rows-in-mysql
http://database.51cto.com/art/201011/235159.htm
添加多字段唯一索引,会自动删除重复数据,并不允许插入重复数据。
查询多字段重复数据
select * from plan_device a
where (a.sourceID,a.platformID, a.sourceType) in (select sourceID,platformID,sourceType from plan_device group by sourceID,platformID,sourceType having count(*) > 1)
执行时间很长。
添加不重复的索引
ALTER IGNORE TABLE plan_device ADD UNIQUE INDEX UNIQUE_KEY (`sourceID`, `platformID`, `sourceType`);
--
-- 2014-9-19
--