Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How can I generate (or get) a ddl script on an existing table in oracle? I have to re-create them in Hive [duplicate]

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.

like image 959
VSJ Avatar asked Oct 08 '14 05:10

VSJ


1 Answers

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;

and spool the output into a SQL script.

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

like image 196
a_horse_with_no_name Avatar answered Oct 12 '22 11:10

a_horse_with_no_name