日期:2014-05-16  浏览次数:20764 次

Mysql oracle删除重复记录的sql
MYSQL
drop TABLE if EXISTS tmp_t;
create TABLE tmp_t select min(id) id,`name`  from comp_info group by `name` having count(`name`)>1 ;
delete a.* from comp_info a,tmp_t b where b.`name`=a.`name` and a.id>b.id;
truncate table tmp_t;
drop TABLE if EXISTS tmp_t;


Oracle
delete from gqh_sch_info 
where sch_name  in (select  sch_name  from gqh_sch_info  group  by  sch_name   having  count(sch_name) > 1)
and rowid not in (select min(rowid) from  gqh_sch_info  group by sch_name  having count(sch_name)>1)