要删除Oracle表中的重复行,可以使用以下方法之一:
WITH CTE AS (
SELECT
column1,
column2,
ROW_NUMBER() OVER (PARTITION BY column1, column2 ORDER BY column1) AS rn
FROM your_table
)
DELETE FROM your_table
WHERE (column1, column2) IN (SELECT column1, column2 FROM CTE WHERE rn > 1);
DELETE FROM your_table a
WHERE EXISTS (
SELECT 1
FROM your_table b
WHERE a.column1 = b.column1
AND a.column2 = b.column2
AND a.rowid > b.rowid
);
无论使用哪种方法,都需要谨慎操作,确保只删除重复行而不是有用的数据。最好在删除之前备份数据以防止意外情况。