通過ROWID刪除重複資料

尛樣兒發表於2010-07-17

SQL> select * from test_rowid;

        ID NAME
---------- ----------------------------------------------------------------------------------------------------
       111 aaa
       222 bb
      3333 cccc
       333 bb
       222 bb
       111 aaa
       111 aaa

7 rows selected.

SQL> delete from test_rowid a where a.rowid!=(select max(b.rowid) from test_rowid b where a.id=b.id and a.name=b.name);

3 rows deleted.

SQL> select * from test_rowid;

        ID NAME
---------- ----------------------------------------------------------------------------------------------------
      3333 cccc
       333 bb
       222 bb
       111 aaa

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/23135684/viewspace-668269/,如需轉載,請註明出處,否則將追究法律責任。

相關文章