2014-03-24 18 views
0

如何查找子表的根表?如何查找子表的根表?

例如: -

I have 26 tables A,B,C ...Z. I need to find the indirect relation for particular table 

B has relation with A 
C has relation with B 

If i will give the table_name like c, it will come to A(indirect relation) 
+0

我不認爲你可以做到這一點。 – Lokesh

回答

1

你可以嘗試和user_constraints

PK使用分層查詢是constraint_type = 'P'

FKconstraint_type = 'R',由r_constraint_name

鏈接到主鍵

沿着這個東西線路可能工作(未測試)

select table_name 
from user_constraints 
start with 
    table_name = 'x' 
    and constraint_type = 'P' 
connect by r_constraint_name = prior constraint_name 
    and prior constraint_type = 'R'