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

  • 相关阅读:
    Splash wait() 方法
    Splash go() 方法
    Splash 对象方法
    短信接口文档
    WMS开发环境
    Eureka
    pom.xml settings.xml
    Druid
    EAI并发
    重启WMS服务
  • 原文地址:https://www.cnblogs.com/brianlai/p/10302654.html
Copyright © 2011-2022 走看看