Oracle通过ROWID删除表中重复记录
-- 1 通过ROWID删除T1表里重复的记录
SELECT ROWID,A,B
--DELETE
FROM T1
WHERE ROWID IN
(
SELECT RD
FROM
(
SELECT A,B, ROWID RD, ROW_NUMBER()OVER(PARTITION BY A,B ORDER BY ROWID ) RN
FROM T1
) T2
WHERE RN<>1
);
--DELETE
FROM T1
WHERE ROWID IN
(
SELECT RD
FROM
(
SELECT A,B, ROWID RD, ROW_NUMBER()OVER(PARTITION BY A,B ORDER BY ROWID ) RN
FROM T1
) T2
WHERE RN<>1
);
SELECT ROWID,A,B
--DELETE
FROM T1
WHERE ROWID NOT IN
(
SELECT MIN(ROWID) AS RD
FROM T1
GROUP BY A,B
);
--DELETE
FROM T1
WHERE ROWID NOT IN
(
SELECT MIN(ROWID) AS RD
FROM T1
GROUP BY A,B
);