Hello,
How can I duplicate a table with all of its attributes?
Thank you
Printable View
Hello,
How can I duplicate a table with all of its attributes?
Thank you
Create table new_tab as Select * from old_tab;
This won't create the indexes tho'
Nor the constraints (except for not null constraints).
exp/imp can do the trick provided that you do the import into a different schema...
Nor the grants, nor the triggers
You could also export the table, then rename it, it's indexes, triggers etc., then import.
There is one package called "DBMS_METADATA" Under that package u can use method "get_ddl".This method gives back the script of the table u have given as a parameter to it.Use this thing in connection with user_tables.This method gives scripts with all constraints and all grants.Spool it to some file and then just change the name of tables in file manually.I think this should solve your problem.:)
DBMS_METADATA is new in 9i.
dbms_metadata.get_ddl does not extract all the indexes but other wise its performance is pretty good.
Can you elaborate on this ? Which indexes are you talking about ?Quote:
Originally posted by cyaniv
dbms_metadata.get_ddl does not extract all the indexes but other wise its performance is pretty good.
Indexes on the table whose definition you are trying to extract with
dbms_metadata.get_ddl('TABLE','TABLE_NAME','SCHEMA')
you can use
dbms_metadata.get_dependent_ddl(object_type,base_object_name,base_object_schema,version,model,transf orm,object_count)
to generate all the indexes for the table though.