zoukankan      html  css  js  c++  java
  • oracle删除一个表内的重复数据,

    查询以及删除一个数据库表内的重复数据。

    1.查询表中的多余的重复记录,重复记录是根据单个字段来判断的。

    select * from biao where id in (select id from biao group by id having count(id) >1 )

    2.删除表中的多余的重复记录,重复记录是根据(id)来判断,只留rowid 最小值。

     delete from  biao where id  in   ( select  id from biao group by id having count(id) )  and  rowid not in  ( select  min(rowid) from  biao group by id having count(id)>1 )

    delete from xuesheng
    where T_NAME in
    (select T_NAME
    from xuesheng
    group by T_NAME, T_ADDRESS, T_PHONE, T_BIRTHDAY
    having count(*) > 1) --重复数据
    and rowid not in
    (select max(rowid)
    from xuesheng
    group by T_NAME, T_ADDRESS, T_PHONE, T_BIRTHDAY
    having count(*) > 1) --保留一条重复数据

    3.删除表中重复的记录(多个字段),

    delete from xuesheng
    where T_NAME in
    (select T_NAME
    from xuesheng
    group by T_NAME, T_ADDRESS, T_PHONE, T_BIRTHDAY
    having count(*) > 1) --不保留重复数据

    来自:https://www.cnblogs.com/252e/archive/2012/09/13/2682817.html

  • 相关阅读:
    推荐一个SAM文件中flag含义解释工具--转载
    字节码技术
    Jconsole工具检测堆内存变化的使用
    观察者模式
    装饰器模式(IO流案例)
    JVM垃圾收集器
    内存溢出与内存泄漏区别
    栈溢出
    内存溢出
    JVM参数调优
  • 原文地址:https://www.cnblogs.com/brianlai/p/10302654.html
Copyright © 2011-2022 走看看