在Oracle中,你可以使用DELETE
语句结合ROWID
和子查询来删除重复的记录。以下是一个示例:
- DELETE FROM your_table
- WHERE ROWID NOT IN (
- SELECT MAX(ROWID)
- FROM your_table
- GROUP BY column1, column2, ... -- 列出用于判断重复的列
- );
原数据:
示例:
- DELETE FROM SJS.CGGL_FWZX_USC_WS_SPYJ_SSFW
- WHERE ROWID NOT IN (
- SELECT MAX(ROWID)
- FROM SJS.CGGL_FWZX_USC_WS_SPYJ_SSFW
- GROUP BY ID -- 列出用于判断重复的列
- );
- COMMIT ;
结果:
- DELETE FROM your_table
- WHERE id NOT IN (
- SELECT MIN(id)
- FROM your_table
- GROUP BY A, B, C
-
- );