You can get duplicate rows by Analytic SQL:
SELECT rid, deptno, job, rn
FROM
(SELECT /*x parallel(a) */
ROWID rid, deptno, job,
ROW_NUMBER () OVER (PARTITION BY deptno, job ORDER BY empno) rn
FROM scott.emp a
)
WHERE rn <> 1;
Get duplicate row count with Count(*) > 0.
SELECT /*x parallel(a,8) */ MAX(ROWID) rid, deptno, job, COUNT(*) FROM scott.emp a GROUP BY deptno, job HAVING COUNT(*) > 1;
To delete them:
DELETE FROM scott.emp
WHERE ROWID IN
(
SELECT rid
FROM (SELECT /*x parallel(a) */
ROWID rid, deptno, job,
ROW_NUMBER () OVER (PARTITION BY deptno, job ORDER BY empno) rn
FROM scott.emp a)
WHERE rn <> 1
);
No comments:
Post a Comment