GeekInterview.com
   Home |  Tech FAQ  |   Interview Questions |  Placement Papers |  Tech Articles |  Learn |  Freelance Projects |  Online Testing |  Geeks Talk |  Job Postings |  Knowledge Base | Site Search |  Add/Ask Question

GeekInterview.com  >  Tech FAQs  >  PL/SQL
Go To First  |  Previous Question  |  Next Question 
 PL/SQL  |  Question 79 of 157    Print  
Suppose one table contain many identical records. Then how to delete only identical Records.

  
Total Answers and Comments: 6 Last Update: March 12, 2007     Asked by: globalanil18 
  
 Sponsored Links

 
 Best Rated Answer

No best answer available. Please pick the good answer available or submit your answer.
February 08, 2007 10:59:57   #1  
madhuk17 Member Since: February 2007   Contribution: 15    

RE: Suppose one table contain many identical records. ...
When a table contains identical records then we can delete them using the following query,lets take an example of emp tabledelete from emp awhere rowid in(select min(rowid) from emp bwhere a.empno=b.empno);
 
Is this answer useful? Yes | No
February 22, 2007 00:30:01   #2  
sat.inn Member Since: February 2007   Contribution: 15    

RE: Suppose one table contain many identical records. ...
hi its not working....it deletes both the duplicate row as well as non identical rows..
 
Is this answer useful? Yes | No
February 22, 2007 01:58:50   #3  
       

RE: Suppose one table contain many identical records. ...
hi its not working....it deletes both the duplicate row as well as non identical rows..
 
Is this answer useful? Yes | No
March 03, 2007 13:52:45   #4  
SANTO        

RE: Suppose one table contain many identical records. ...
Hi,

you can check it out with this query to delete duplicate records.

suppose a table called temp contains identical rows in the column say 'name', then we can delete those rows with the following query.

DELETE FROM TEMP A
WHERE ROWID >(SELECT MIN(ROWID) FROM TEMP B
                               WHERE A.NAME = B.NAME);

 
Is this answer useful? Yes | No
March 05, 2007 14:27:12   #5  
suni123 Member Since: March 2007   Contribution: 1    

RE: Suppose one table contain many identical records. ...
Hi,

To delete duplicate rows from table EMP

DELETE FROM EMP WHERE ROWID NOT IN
                   (SELECT
MAX(ROWID) FROM EMP GROUP BY empno)

(OR)

DELETE FROM EMP WHERE ROWID NOT IN
         (SELECT MIN(ROWID) FROM EMP GROUP BY empno)


Thanks,
Suneetha.


 
Is this answer useful? Yes | No
March 12, 2007 05:52:34   #6  
Nikhil_4_Oracle        

RE: Suppose one table contain many identical records. ...
Hey,

Above Soln is not working with tables where data is like,

COL1
 ----------
15
11 *
70
81
11 *
55
11 *
78

--Here 11 Repeats 3 times fine...

--Check d rowid
select rowid,col1 from nodup;

ROWID                    COL1
------------------ ----------
AAAOV+AAAAAAAJ0AAA         15
AAAOV+AAAAAAAJ0AAB         11  --> Take this RowId
AAAOV+AAAAAAAJ0AAC         70
AAAOV+AAAAAAAJ0AAD         81
AAAOV+AAAAAAAJ0AAE         11
AAAOV+AAAAAAAJ0AAF         55
AAAOV+AAAAAAAJ0AAG         11
AAAOV+AAAAAAAJ0AAH         78


--Now Delete Dup val.

delete from nodup
where col1=11
And
Rowid <> 'AAAOV+AAAAAAAJ0AAB';

This wll Rocks Honey.......

Bye

Nikhil.

 
Is this answer useful? Yes | No


 
Go To Top


 Sponsored Links

 




About Us  |   Privacy Policy  |   Terms and Conditions  |   Contact  |   Site Map  |   Add Question  |   Propose Category  |   RSS Feeds  |   Articles Sitemap  |   Site Updates  |   Add Resource

Copyright © 2005 - 2008 GeekInterview.com. All Rights Reserved
Page copy protected against web site content infringement by Copyscape