在一个很大的表中有记录相同的,求一条去除重复记录的语句。怎么写效率最快?

解决方案 »

  1.   

    select distinct * from tb
      

  2.   

    http://topic.csdn.net/u/20080626/00/43d0d10c-28f1-418d-a05b-663880da278a.html?9990
    參照
      

  3.   

    不好意思,我昨天说的有些不清楚,是删除。
    http://topic.csdn.net/u/20080626/00/43d0d10c-28f1-418d-a05b-663880da278a.html?9990 
    上的删除方法,删除很多数据时用那种快一些
      

  4.   

    第三种
    select
     *
    from 
     tb t
    where
      id=(select max(id) from tb where col=t.col)
      

  5.   

    DELETE T FROM TB T WHERE id=(select max(id) from tb where col=t.col)
      

  6.   

    先查出没有重复的放在临时表中
    再用这个表和临时表关联inner join 删除没有关联上的  
    剩下的就是没有重复的  比直接删除要快
      

  7.   

    delete
    t
    from 
     tb t
    where
      id=(select max(id) from tb where col=t.col)这个把表中没有重复的记录也删除了