oracle 全網相同資料刪除(只留一條),oracle一條

來源:互聯網
上載者:User

oracle 全網相同資料刪除(只留一條),oracle一條

DELETE   FROM reg_user t1   WHERE user_name='9527008' and rowid > ( SELECT min(rowid)   FROM location t2   WHERE t1.user_name= t2.user_name);


在Oracle中怎用一條sql語句重複資料刪除的資料(留一條資料)

delete Emp p
where rowid in
(
select tmpid
(select ROW_NUMBER() OVER(PARTITION BY id ) id ,rowid tmpid from emp )
where id <> 1
)

可以試試
 
oracle資料庫怎重複資料刪除資料只留一個?

delete from GXS_VIEW_PATIENT_INFO where rowid not in (select min(rowid) from GXS_VIEW_PATIENT_INFO group by 某欄位)
某欄位就是按照某幾個分組

比如資料
id name
1 a
1 a
1 a

你最後group by id或者group by name都可以
但是如果
id name
1 a
1 a
1 a
2 a
但是像上邊這樣,最後也只能保留一條,所以你得找到一個group by 的欄位

不過這個慎用,資料多的時候會很慢的,刪除前備份一下資料吧

 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.