系统集成论坛

标题: oracle删除重复数据方法 [打印本页]

作者: 思考的牛    时间: 2012-5-23 12:09
标题: oracle删除重复数据方法
删除ORACLE重复的数据常用方式,根据rowid来编写SQL脚本:

    delete from t_web

    where rowid in (select a.rowid, a.web_name

    from t_web a, t_web b

    where a.rowid > b.rowid

    and a.web_name = b.web_name);

    delete from t_web a

    where rowid not in

    (select max(b.rowid) from t_web b  where a.web_name = b.web_name )

    delete from t_web

    where rowid not in (select max(rowid) from t_web a group by a.web_name);

    delete from tbl

    where (col1, col2) in

    (select col1, col2 from tblgroup bycol1, col2havingcount(*) > 1)

    and rowidnotin(selectnin(rowid) fromtblgroup bycol1,

    col2havingcount(*) > 1);




欢迎光临 系统集成论坛 (http://bbs.xtjc.com/) Powered by Discuz! X3.1