/** * 删除重复数据,最终保留一条在库里。 * 处理步骤: * 1. 查询重复数据。 * 2. 删除一条以上的重复数据 */ DELETE FROM [TABLE_NAME_A] A WHERE 1=1 AND A.REPART_COLUMN IN ( SELECT * FROM (SELECT B.REPART_COLUMN FROM [TABLE_NAME_B] B GROUP BY B.REPART_COLUMN HAVING COUNT(B.REPART_COLUMN)>1)AB ) AND A.ID NOT IN ( SELECT * FROM (SELECT MIN(C.ID) FROM [TABLE_NAME_B] C GROUP BY C.REPART_COLUMN HAVING COUNT(C.REPART_COLUMN)>1)AC ) /** * 数据修改 * 1. 多列数据同时修改。 */ UPDATE [TABLE_NAME_A] A SET (ID,CODE,NAME)= ( SELECT B.ID,B.CODE,B.NAME FROM [TABLE_NAME_B] B WHERE A.ID=B.ID ) /** * 恢复删除的表 */ FLASHBACK TABLE ASASS TO BEFORE DROP;