Skip to Main Content

SQL & PL/SQL

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!

Best way to clone a table?

395981Jul 20 2004 — edited Jul 21 2004
Hi,

What is the best way to clone an existing table definition?
What I mean is, I want to do the following:

create table tab2 as
select * from tab1;
delete from tab2;
commit;


But clearly this involves copying all the data and then delete it. Is there a more efficient way?

Another alternative I could think of is:

create table tab2 as
select * from tab1 where rownum < 2;
delete from tab2;
commit;


This would copy only one row instead of all the rows in tab1. This is clearly much more efficient than the first approach, but I still don't like the idea of copying the data and deleting it.

I am sure there would be a "cleaner" way. Any ideas?

Thanks in advance,
Rajesh
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Aug 18 2004
Added on Jul 20 2004
16 comments
692 views