It's easy to introduce duplicate rows of data into Oracle tables by running a data load twice without the primary key or unique indexes created or enabled.
Here's how you remove the duplicate rows before the primary key or unique indexes can be created:
Here column1, column2, column3 constitute the identifying key for each record.
Be sure to replace our_table with the table name from which you want to remove the duplicate rows. The GROUP BY is used on the columns that make the primary key for the table. This script deletes each row in the group after the first row.
Here's how you remove the duplicate rows before the primary key or unique indexes can be created:
DELETE FROM our_table
WHERE rowid NOT IN
(SELECT MIN(rowid)
FROM our_table
GROUP BY column1, column2, column3... ;
Here column1, column2, column3 constitute the identifying key for each record.
Be sure to replace our_table with the table name from which you want to remove the duplicate rows. The GROUP BY is used on the columns that make the primary key for the table. This script deletes each row in the group after the first row.
Oracle中删除重复行
本文介绍了一种在Oracle数据库中删除表内重复行的方法,在创建主键或唯一索引之前,可以通过运行特定的DELETE语句来实现这一目标。该过程确保只保留每组中的第一条记录。
7004

被折叠的 条评论
为什么被折叠?



