Oracle - Clone table - Structure, data constraints and all

I know that I can copy the structure and data as a story

create table testtable1 as select * from sourcetable 

Is there a way to actually clone everything, triggers, constraints, grants, etc.

Thanks in advance. We are launching 10G.

+4
source share
1 answer

Take a look at dbms_metadata , especially its dbms_metadata.get_ddl procedure (see tahiti link ).

So in your case, you will first do

 select dbms_metadata.get_ddl('TABLE', 'SOURCETABLE') from dual; 

Now here is a comment: don't forget dbms_metadata.get_dependent_ddl :

 select dbms_metadata.get_dependent_ddl('TABLE', 'SOURCETABLE') from dual; 

And then work with this output.

+9
source

Source: https://habr.com/ru/post/1445974/


All Articles