oracle查找重复记录和删除

752阅读 0评论2011-04-25 yzgname
分类:Oracle

查找重复记录:
select *
from dept_m
where dept_cd in 
 (
select dept_cd
from KOUSU_DEPT_M
group by dept_cd
having count(dept_cd) > 1
 )

删除重复记录:
delete
from
dept_m
where
dept_cd in 
(
select dept_cd from KOUSU_DEPT_M
group by 
dept_cd 
having count(dept_cd) > 1
)
and rowid not in
(
select min(rowid) from KOUSU_DEPT_M
group by dept_cd
having count(dept_cd) > 1
)
上一篇:关于JK的 sticky_session
下一篇:永远的兄弟 -- 我是特种兵主题曲