日韩性视频-久久久蜜桃-www中文字幕-在线中文字幕av-亚洲欧美一区二区三区四区-撸久久-香蕉视频一区-久久无码精品丰满人妻-国产高潮av-激情福利社-日韩av网址大全-国产精品久久999-日本五十路在线-性欧美在线-久久99精品波多结衣一区-男女午夜免费视频-黑人极品ⅴideos精品欧美棵-人人妻人人澡人人爽精品欧美一区-日韩一区在线看-欧美a级在线免费观看

歡迎訪問 生活随笔!

生活随笔

當(dāng)前位置: 首頁 > 编程资源 > 编程问答 >内容正文

编程问答

Oracle 重复数据查询以及删除

發(fā)布時間:2024/1/23 编程问答 37 豆豆
生活随笔 收集整理的這篇文章主要介紹了 Oracle 重复数据查询以及删除 小編覺得挺不錯的,現(xiàn)在分享給大家,幫大家做個參考.

視頻課:https://edu.csdn.net/course/play/7940

Create table test

(id number(2),


?names varchar2(20));


?insert into test values(1,'張三');
?insert into test values(2,'李四');
?insert into test values(3,'馬七');

?select * from test;


?--查找重復(fù)數(shù)據(jù)
select * from test a where (a.id,a.names) in

?(select id,names from test group by id,names having count(*) > 1)


?--刪除重復(fù)數(shù)據(jù),只留rowid最小的那行;
?delete from test a where (a.id,a.names) in

?(select id,names from test group by id,names having count(*) > 1)


? and rowid not in (select min(rowid) from test group by id,names having count(*)>1)
? --查找重復(fù)數(shù)據(jù),不含rowid最小的行
? select * from test a where (a.id,a.names) in
? (select id,names from test group by id,names having count(*) > 1)
? and rowid not in (select min(rowid) from test group by id,names having count(*)>1)

?

---1.以上是重復(fù)數(shù)據(jù)根據(jù)多列來判斷


以下是重復(fù)數(shù)據(jù)根據(jù)單列來判斷

1、首先,查找表中多余的重復(fù)記錄,重復(fù)記錄是根據(jù)單個字段(id)來判斷

?

select * from test where id in(select id from test group by having count(id) >1)

?

2、刪除表中多余的重復(fù)記錄,重復(fù)記錄是根據(jù)單個字段(id)來判斷,只留有rowid最小的記錄

?

delete from test where (id) in (select id from test group by id having count(id) >1) and rowid not in (select min(rowid) from test group by id having count(*)>1)



總結(jié)

以上是生活随笔為你收集整理的Oracle 重复数据查询以及删除的全部內(nèi)容,希望文章能夠幫你解決所遇到的問題。

如果覺得生活随笔網(wǎng)站內(nèi)容還不錯,歡迎將生活随笔推薦給好友。