據(jù)據(jù)Oracle帶的rowid屬性,進(jìn)行判定,是否存在重復(fù),語句如下: 查數(shù)據(jù): select * from table1 a where rowid !=(select max(rowid) from table1 b where a.name1=b.name1 and a.name2=b.name2......) 刪數(shù)據(jù): delete from table1 a where rowid !=(select max(rowid) from table1 b where a.name1=b.name1 and a.name2=b.name2......)
2.group by方法
查數(shù)據(jù): select count(num), max(name) from student --列出重復(fù)的記錄數(shù),并列出他的name屬性 group by num having count(num) >1 --按num分組后找出表中num列重復(fù),即出現(xiàn)次數(shù)大于一次 刪數(shù)據(jù): delete from student group by num having count(num) >1 這樣的話就把所有重復(fù)的都刪除了。
3.用distinct方法 -對于小的表比較有用
create table table_new as select distinct * from table1 minux truncate table table1; insert into table1 select * from table_new;