oracle刪除表中的重複資料

2021-07-03 12:31:07 字數 305 閱讀 7466

遇到這麼個問題,有一張表test,其中有id,name,age,***,address,等字段,其中id值主鍵,現在要刪除表test中name和age,***相同的重複資料,只保留一條即可。

這是乙個比較常用的sql但是我一下沒寫出來,回頭想想這就是乙個簡單的巢狀子查詢的例項。

sql:delete test a where a.id ! = (select min(id) from test b where a.name=b.name and a.age=b.age and a.*** = b.***);

就是把乙個表當成兩個表來做子查詢就好了;

Oracle刪除表中重複資料

1.建立臨時表 備份全部資料到 create table tmap.t comm customer col log 731all as select from tmap.t comm customer col log 2.建立臨時表 備份資料 去除重複項 create table tmap.t co...

刪除表中重複資料

刪除表中重複資料 取出line fancy2表中fancy name相同的最小fancy id 寫進tmp表 create table tmp as select min fancy id as col1 from line fancy2 group by fancy name 刪除line fan...

刪除表中重複資料

如果重複資料很多,被刪掉的可能是大部分記錄,業務又允許的情況下,可以考慮重建表 create table newtable as select distinct from table rename table to oldtable rename newtable to table create i...