一个没有主键的表中存在大量重复的记录,利用RowID查找重复记录和删除重复记录。

解决方案 »

  1.   

    http://www.wangchao.net.cn/bbsdetail_1779760.html
    或者http://www.google.com/search?hl=en&source=hp&q=%E7%94%A8RowID%E6%9F%A5%E6%89%BE%E9%87%8D%E5%A4%8D%E8%AE%B0%E5%BD%95&btnG=Google+Search&aq=f&oq=&aqi=
      

  2.   

     id为表中的一个字段,不一定是主键!查询相同的记录的三种方法
    1.select * from test t where t.rowid > (select min(x.rowid) from test x where t.id = x.id);
    2.select * from test t where t.rowid <> (select max(x.rowid) from test x where t.id = x.id);
    3.select count(*),t.id, t.name from test t group by id,name having count(*) > 1;删除重复记录的两种方法:
    1.delete from test t where t.rowid > (select min(x.rowid) from test x where t.id = x.id);
    2.delete from test t where t.rowid <> (select max(x.rowid) from test x where t.id = x.id);
      

  3.   

    这个问题在我的主页中有:http://blog.csdn.net/huangyunzeng2008/archive/2009/10/08/4643598.aspx