Oracle - 克隆表 - 结构、数据约束和所有
声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow
原文地址: http://stackoverflow.com/questions/13377030/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me):
StackOverFlow
Oracle - Clone table - Structure, data constraints and all
提问by Dr.Avalanche
I know I can copy a tale structure and data by
我知道我可以通过以下方式复制故事结构和数据
create table testtable1 as select * from sourcetable
Is there any way to actually clone everything, triggers, constraints, grants etc?
有没有办法真正克隆所有内容、触发器、约束、授权等?
Thanks in advance. We are running 10G.
提前致谢。我们正在运行10G。
回答by René Nyffenegger
Take a look into dbms_metadata
, especially its procedure dbms_metadata.get_ddl
function (see this tahiti link).
看一看dbms_metadata
,尤其是它的程序dbms_metadata.get_ddl
功能(参见这个tahiti 链接)。
So, in your case, you would first do a
所以,在你的情况下,你会先做一个
select dbms_metadata.get_ddl('TABLE', 'SOURCETABLE') from dual;
As per be here now's comment: dont forget the dbms_metadata.get_dependent_ddl
:
根据现在的评论:不要忘记dbms_metadata.get_dependent_ddl
:
select dbms_metadata.get_dependent_ddl('TABLE', 'SOURCETABLE') from dual;
And then work from the given output.
然后从给定的输出开始工作。