Deleting Duplicate Keys

How to delete duplicate Keys through PL-SQL in single query.

Showing Answers 1 - 7 of 7 Answers

ramniwas

  • Sep 5th, 2011
 

Code
  1.  

  Was this answer useful?  Yes

Pavan

  • Sep 7th, 2011
 

delete from where rowid in (select max/min(rowid) from group by having count(*)>1)

  Was this answer useful?  Yes

iftekhar

  • Sep 20th, 2011
 

Code
  1.  

  Was this answer useful?  Yes

Art11

  • Sep 21st, 2011
 

To make my prev. posts readable...

Replace select with delete:

SELECT ename FROM emp1 e WHERE ROWID > (SELECT MIN(rowid) FROM emp1 WHERE ename = e.ename)

  Was this answer useful?  Yes

Art11

  • Sep 21st, 2011
 

Assuming that ename and job is the same or First and Last name...

SELECT * FROM (SELECT empno, ename, job ,RANK() OVER (PARTITION BY ename, job ORDER BY empno) AS SeqNo FROM emp1) WHERE SeqNo > 1

  Was this answer useful?  Yes

anonymous

  • Sep 27th, 2011
 

Code
  1.  

  Was this answer useful?  Yes

Give your answer:

If you think the above answer is not correct, Please select a reason and add your answer below.

 

Related Answered Questions

 

Related Open Questions