oracle中表中重复数据去重,主要是通过举例子来说明
首先创建测试表以及测试数据
create table t1 as select * from all_objects; insert into t1 select * from all_objects where rownum < 101;
这里面有重复的数据100条
第一种方法是集合的方法
select * from t1
where rowid in (
select rowid from t1
minus
select max(rowid) from t1 group by object_id);
另一种是分析函数的
select *
from t1
where rowid in
(select rd
from (select rowid rd, row_number() over(PARTITION BY object_id order by object_id) rn
from t1)
where rn <> 1)
然后再delete就ok了。当然还有很多的去重方法,在以后慢慢的研究。