leolo’s Blog



在Oracle中找出重複的紀錄的方法

在Oracle中找出重複的紀錄的方法
SELECT aid FROM atable GROUP BY aid HAVING COUNT(*) >1;

刪除重複的記錄
DELETE FROM atable a where a.ROWID!=(SELECT MAX(ROWID) FROM atable b WHERE a.aid=b.aid;


發表迴響

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / 變更 )

Twitter picture

You are commenting using your Twitter account. Log Out / 變更 )

Facebook照片

You are commenting using your Facebook account. Log Out / 變更 )

連結到 %s

Follow

Get every new post delivered to your Inbox.