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)
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. 把没重复的数据备份出来
create table tab_test
select distinct * from table_name2。 把原表数据删除
3。 把TAB_TEST 表导到原来表中,或RENAME成原来的表 并建好INDEX
先把表 delete 掉, 然后把数据 insert进去
在之间不要 commit
insert完成后再commit
这样应该不影响数据库的使用
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))
即可选出重复的记录
然后全部删除,速度快得多!
当然,缺点是我只能删除所有重复记录,而不是其中的一条。
http://dev.csdn.net/develop/article/75/75420.shtm