Oracle FAQ Your Portal to the Oracle Knowledge Grid
HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US
 

Home -> Community -> Usenet -> c.d.o.misc -> Re: How to delete all rows in a table except for 10 of them?

Re: How to delete all rows in a table except for 10 of them?

From: Allen Kirby <akirby_at_att.com>
Date: 1997/03/20
Message-ID: <33319A91.4FC0@att.com>#1/1

You could try this - it may be faster than deleting, and should work for any table (warning - may not be syntactically correct - don't have my manual right now)

create table new_table as select * from old_table where rownum < 11; truncate old_table;
insert into old_table select * from new_table; drop table new_table;

OR, if you don't care where the new table is:

create table new_table as select * from old_table where rownum < 11; drop table old_table;
rename new_table to old_table;

-- 
---
Allen Kirby			AT&T ITS Production Services
akirby_at_att.com			Alpharetta, GA.
Received on Thu Mar 20 1997 - 00:00:00 CST

Original text of this message

HOME | ASK QUESTION | ADD INFO | SEARCH | E-MAIL US