3

I want to generate the DDL of an object which a synonym points to. Consider the below example.

I have a synonym named USER which points to USER_1 table. I want to generate DDL of the USER_1 table using the synonym as input.

I need to generate for over 400 synonyms, hence searching for a method to retrieve DDL using synonyms.

Thanks in advance.

2
  • What kind of DDL statement you want to generate. Commented Jun 30, 2017 at 22:43
  • DDL of the object(table in my case) which a synonym is pointing to.
    – Arun Kumar
    Commented Jul 1, 2017 at 8:01

1 Answer 1

2

For tables:

select dbms_metadata.get_ddl('TABLE', table_name)
from user_synonyms
where synonym_name in ...;

For other object types as well:

select dbms_metadata.get_ddl(o.object_type, s.table_name)
from user_synonyms s join user_objects o on (s.table_name = o.object_name)
where s.synonym_name in ...;
2
  • any way to do it using Toad for Oracle?
    – Arun Kumar
    Commented Jul 3, 2017 at 9:29
  • I've done this using Export DDL option which is available in Toad for Oracle.
    – Arun Kumar
    Commented Jun 13, 2018 at 6:16

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.