莫愁前路无知己,天下谁人不识君。。。。

Oracle删除重复记录妙解

上一篇 / 下一篇  2017-08-17 20:15:53 / 个人分类:数据库知识

少量数据:
三部曲:
1.create table a as select distinct *  from b;
2.truncate table b;
3.insert into b select * from a;

大量数据:
way1:  delete from test a where rowid not in(select max(b.rowid) from test b where a.id=b.id and a.name=b.name...)
way2:  delete from test a where rowid <(select max(b.rowid) from test b where a.id=b.id.....)(换>,则 max换min)
way3:  delete from test where rowid not in (select max(rowid) from test a group by a.id,a.name...)

TAG: 数据库Oracle

 

评分:0

我来说两句

Open Toolbar