• Oracle 删除重复数据的几种方法


    去重
    第一种:distinct
    create table tmp_t3 as select distinct * from t3;
    drop table t3;
    alter table tmp_t2 rename to t3;
    -- 第二种,用rowid
    delete from t2
        where rowid <>( select min(rowid)
                         from t2 b
                         where b.c1 = t2.c1
                           and b.c2 = t2.c2 )
     
    ---第三种, 用rowid + group by 的方法
    delete from T2
        where rowid not in (select min(rowid)
        from t2 group by c1,c2 );
     
    delete from t2 
    where not exists (select 1 from (select min(rowid) rid from t2 group by c1,c2) b where b.rid=t2.rowid)
     
    ---第四种, 用分析函数
    delete from t2 where rowid in 
    (select b.rd from 
    (select rowid rd,row_number() over(partition by c1,c2 order by c1) rn 
    from t2) b 
    where b.rn > 1);
  • 相关阅读:
    Linq To Sql 大全
    lambda表达式学习
    一步一步学Linq to sql系列文章
    MVC 学习
    Guava环境设置
    ANT简介
    Quartz特点
    XStream环境设置
    log4j配置
    类是什么?
  • 原文地址:https://www.cnblogs.com/liang545621/p/9407505.html
Copyright © 2020-2023  润新知