Home » SQL & PL/SQL » SQL & PL/SQL » Cloning a table (Oracle
Cloning a table [message #376328] Wed, 17 December 2008 00:20 Go to next message
Messages: 119
Registered: August 2007
Senior Member

I wish to create an exact copy of a table with its triggers, primary keys, indexes and data.

Is there a way to do the same?

create table emp_new as select * from emp;

only creates the table with the data.



[Updated on: Wed, 17 December 2008 00:24]

Report message to a moderator

Re: Cloning a table [message #376330 is a reply to message #376328] Wed, 17 December 2008 00:48 Go to previous messageGo to next message
Michel Cadot
Messages: 65084
Registered: March 2007
Location: Nanterre, France, http://...
Senior Member
Account Moderator
Use DBMS_METADATA to create the object and dependencies then insert into it.

Re: Cloning a table [message #376338 is a reply to message #376328] Wed, 17 December 2008 01:13 Go to previous message
Messages: 21127
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
I guess that you don't want to do that in the same schema where the original table is (as you can't have more than one index, primary key, etc. having the same name as the existing one).

Therefore, EXPORT and IMPORT utilities might be another choice.
Previous Topic: dbms_job sumbit various dates
Next Topic: creating file on server
Goto Forum:

Current Time: Sun Jul 23 10:15:18 CDT 2017

Total time taken to generate the page: 1.23168 seconds