Skip to Main Content

Oracle Database Discussions

Announcement

For appeals, questions and feedback about Oracle Forums, please email oracle-forums-moderators_us@oracle.com. Technical questions should be asked in the appropriate category. Thank you!

TRACING RELATIONSHIP BETWEEN TABLES....

693241May 22 2009 — edited May 22 2009
Hello all,

I use the below query to find the hierarchial relationship between tables ...

SELECT
c.table_name parent_table , c.column_name parent_column,b.table_name child_table ,b.column_name child_COLUMN ,LEVEL lrv
FROM USER_constraints a,user_cons_columns b ,user_cons_columns c
WHERE a.constraint_name = b.constraint_name
AND a.r_constraint_name = c.constraint_name
AND constraint_type = 'R'
AND b.table_name <> 'CNTRCT_PARENT'
START WITH b.table_name = 'CNTRCT_PARENT'
CONNECT BY NOCYCLE PRIOR b.table_name = c.table_name
ORDER BY c.table_name


but i need order like below,


parent table childtable1
childtable1 grantchildtable1
childtable1 grantchildtable2
parent table childtable2
childtable2 grantchildtable1
childtable2 grantchildtable2
childtable2 grantchildtable3


how this sort of order by is possible ...



Thanks in advance
Vijay G
Comments
Locked Post
New comments cannot be posted to this locked post.
Post Details
Locked on Jun 19 2009
Added on May 22 2009
1 comment
279 views