本文介绍了如何在oracle中的现有表上生成(或获取)ddl脚本?我必须在Hive中重新创建它们的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何在oracle中的现有表上生成DDL脚本?我正在做一个项目,在这个项目中,我必须重新创建Oracle表中存在的某些表到Hive中.

How can I generate a DDL script on an existing table in oracle? I am working on a project where I have to re-create some tables that are present in Oracle table into Hive.

推荐答案

如果您的SQL客户端不支持此功能,则可以使用dbms_metadata包获取数据库中几乎所有内容的源代码:

If your SQL client doesn't support this, then you can use the dbms_metadata package to get the source for nearly everything in your database:

对于表,使用类似以下内容的内容:

For a table use something like this:

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

您还可以一次对所有表执行此操作:

You can also do this for all tables at once:

select dbms_metadata.get_ddl('TABLE', table_name)
from user_tables;

并将输出后台处理到SQL脚本中.

and spool the output into a SQL script.

更多详细信息在手册中: http://docs .oracle.com/cd/E11882_01/appdev.112/e40758/d_metada.htm

More details are in the manual: http://docs.oracle.com/cd/E11882_01/appdev.112/e40758/d_metada.htm

这篇关于如何在oracle中的现有表上生成(或获取)ddl脚本?我必须在Hive中重新创建它们的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

11-03 11:55