星期一, 5月 17, 2010

oracle 快速刪除重複的記錄

http://tech.163.com/06/0621/09/2K4NLFRH00091LRE.html
-
利用rowid

在oracle中,每一條記錄都有一個rowid,rowid在整個資料庫中是唯一的,rowid確定了每條記錄是oracle中的哪一個資料檔案、block、行上。在重複的記錄中,可能所有列的內容都相同,但rowid不會相同。SQL語法如下:


delete from tbl where rowid in (select a.rowid from tbl a, tbl b where a.rowid>b.rowid and a.col1=b.col1 and a.col2 = b.col2)

沒有留言:

LinkWithin-相關文件

Related Posts Plugin for WordPress, Blogger...