Oracle Scenarios Question:

How we remove duplicate rows in table?

Tweet Share WhatsApp

Answers:

Answer #1select * from employee a where rowid not in(Select min(rowid) from employee b where b.emp_id = a.emp_id)

Answer #2delete from emp where rowid not in (select max(rowid) from emp group by empid )

Answer #3select * from employee a where rowid in (select min(rowid) from employee b where a.emp_id=b.emp_id)


Answer #4select count(*), all_columns from table_name group by all_columns having count(*) > 1;

Answer #5DELETE FROM TABLENAME WHERE ROWID NOT IN (SELECT MAX(ROWID) FROM TABLENAME GROUP BY DUPLICATECOLUMNNAME);

Answer #6DELETE FROM EMP
WHERE ROWID NOT IN
(SELECT MIN(ROWID) FROM EMP
GROUP BY EMPNO);

Download Oracle Scenarios PDF Read All 23 Oracle Scenarios Questions
Previous QuestionNext Question
Explain about the oracle disaster recovery scenarios?How to append data in a file from one server to another server?