1.只能找出表中非重复行,可以通过临时表过渡,利用不重复列rowid完成原表中重复行的删除
select distinct(*) from T;
2.查出表中的重复行
select * from T where num in (select num from T group by num having count(*)>1);
3.利用单条SQL语句完成表中重复行的删除--最为经典
delete from T where
num,key in (select num,key from T group by num,key having count(*)>1)
and rowid not in (select min(rowid) from T group by num,key having count(*)>1);
4.抛弃rowid字段,使用identity函数建立新的id字段列,与两个临时表一起完成重复行的删除
insert into table T1 select identity(int ,1,1) as autoID,* from T;
insert into table T2 select min(autoID) from T1 group by num,key;
select * from T1 where autoID in (selelct autoID from T2);