본문 바로가기

DATABASE

[Oracle]ROWID를 이용한 중복 데이터 삭제

출처 : http://blog.quenam.net/? document_srl=24035

두번째 방법이 더 유연하게 처리가 가능.

------------------------------------------------------------------------------------------------------------

delete from
table
where
rowid in
(
select rowid
from
(
select
rowid,
row_number() over(partition by key order by key) no
from table
)
where no !=1
);
------------------------------------------------------------------------------------------------------------
delete from
table a
where a.rowid >
(
select min(b.rowid)
from talbe b
where a.key = b.key
);