sql删除重复数据
如果该表需要删除重复的记录(重复记录保留1条),可以按以下方法删除
select distinct * into #Tmp from tableName
drop table tableName
select * into tableName from #Tmp
drop table #Tmp
另一种方法是一个字段重复,ID不重复
delete 表 where id not in(
SELECT MAX(id) AS id FROM 表 GROUP BY rows) --- 删除重复行
select * from 表 where id in(
SELECT MAX(id) AS id FROM 表 GROUP BY rows) --重复行只查询一条
Oracle删除重复数据
delete from tb
where rowid not in (select min(rowid) from tb group by 重复字段 having count(重复字段)>1)