delete from table_name t1 where rowid <>(
select max(rowid) from table_name t2 where t1.starttime=t2.starttime
t1.endtime=t2.endtime and t1.callingnumber=t2.callingnumber 
and t1.callednumber=t2.callednumber and t1.calltime=t2.calltime)

解决方案 »

  1.   

    或者 
    1. 把没重复的数据备份出来
    create table tab_test
    select distinct * from table_name2。 把原表数据删除
    3。 把TAB_TEST 表导到原来表中,或RENAME成原来的表 并建好INDEX
      

  2.   

    那就用地二种方法
    先把表 delete 掉, 然后把数据 insert进去
    在之间不要 commit
    insert完成后再commit
    这样应该不影响数据库的使用
      

  3.   

    找到了更好的方法,思想:将其中几个键挑出来,作为主键,比如有四个键:a、n、r、r2 联合起来存在唯一性,只要:
    select * from test where a||n||r||r2 in (select a||n||r||r2 from test group by a||n||r||r2 having(count(a||n||r||r2)>1))
    即可选出重复的记录
    然后全部删除,速度快得多!
    当然,缺点是我只能删除所有重复记录,而不是其中的一条。
      

  4.   

    以前不是有篇文档专门说如何删重复记录的吗?用rowid已经是最快的了
    http://dev.csdn.net/develop/article/75/75420.shtm