Is there a way to create a table that displays tables in order of table with PK first then tables with FK?
displaying a table with PK first then FK?
Collapse
X
-
-
-
Try this query:
[code=oracle]
SELECT acc.table_name Table_Name,
acc.constraint_ name Constraint_Name ,
acc.column_name Column_Name,
DECODE(ac.const raint_type,'P', 'Primary Key','R','Forei gn Key',ac.constra int_type) Constraint_Type ,
ac.r_constraint _name Referred_Constr aint_Name,
(SELECT DISTINCT table_name FROM all_constraints where constraint_name = ac.r_constraint _name) Reffered_Table_ name
FROM
all_cons_column s acc,all_constra ints ac
WHERE
acc.constraint_ name = ac.constraint_n ame
AND ac.constraint_t ype IN ('P','R')
ORDER BY
acc.table_name, 4 DESC
[/code]Comment
Comment