Get Table dependent primary and foreign key independently
VIRUDec 25 2011 — edited Dec 25 2011Hi,
I am using ORACLE 11g R2.
I want to get the DDL of all tables in my schema, so i am using the dbms_metadata.get_ddl() function. This returns me the DDL for tables but again i want to execute all these DDL's in another schema. while executing it should follow the order of first creating tables, all tables for the schema without any constraints on it. So in this scenario all the tables will get created. Then i want to apply all the primary key constraints first , and then all the unique key constraints and then the forengin key constraints. For the same purpose i am using the below function "dbms_metadata.get_dependent_ddl() ,
The issue is that this function returns both the primary and foreign key constraint statements
{code}
select dbms_metadata.get_dependent_ddl( 'CONSTRAINTS_AS_ALTER', table_name) DDL
FROM USER_TABLES WHERE table_name = 'EMPLOYEES' ;
{code}
Is their a way in which i could ask the alter table constraint statements for only the primary key first and then for unique key and then for foreign key?
Please let me know as per. I want to get alter table constraint statements for tables separately for each key constraints.
Thanks in advance.