how to get the DDL of a table with different schema

I have few databases and all the databases have the same tables (i.e. table names). Now i want to get the DDL of the table with different schema.

Upvotes: 1

Views: 2107

Answers (1)

Popeye
Popeye

Reputation: 35930

Use the dbms_metadata package to get the DDL of any object of the DB.

SELECT
    DBMS_METADATA.GET_DDL('<Object type>', '<Object name>', '<object schema>')
FROM
    DUAL; -- How to

SELECT
    DBMS_METADATA.GET_DDL('TABLE', 'MY_TABLE', 'MY_SCHEMA')
FROM
    DUAL; -- In your case use something like this

Also, You can format the output using dbms_metadata.set_transform_param.

See Oracle documentation for more information on it.

Cheers!!

Upvotes: 3

Related Questions