Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

Delete duplicate records from table

874450Aug 3 2011 — edited Aug 3 2011
CREATE GLOBAL TEMPORARY TABLE MyTable1 (
Name1 varchar2(100)

);

insert into MyTable1 values ('11');
insert into MyTable1 values ('11');
insert into MyTable1 values ('11');
insert into MyTable1 values ('11');
insert into MyTable1 values ('12');
insert into MyTable1 values ('12');

select * from MyTable1

I want to delete duplicate names from MyTable1..And after delete I should have 11 and 22 only.

I can do this using below query but it seems to be not efficient way. Is there any other way to do this?

delete from MyTable1
where rowid not in
(select max(rowid)
from MyTable1
group by Name1
)

Edited by: 871447 on Aug 3, 2011 12:47 PM
This post has been answered by mseberg on Aug 3 2011
Jump to Answer
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 31 2011
Added on Aug 3 2011
8 comments
3,059 views