How to find the foreigner from one table to another by Oracle?

2

When we are executing SQL statements and we need to navigate between tables it is simple when we know the database modeling to apply JOIN and GROUP BY , but when we do not know, what to do? Is it necessary to apply DESC Table in the tables to know what the foreign keys are?

Is there any command in oracle that shows us the foreign keys between the tables?

that would be the form;

select f.table_name, t.table_name, t.column_name, f.constraint_name, t.owner
from all_cons_columns t, all_constraints f
where f.r_owner = t.owner
 and f.table_name = 'PARCELAMENTO'
 and f.r_owner='root';
    
asked by anonymous 20.01.2016 / 12:51

1 answer

3

With this select you can see the parent and child tables

select f.table_name, t.table_name, t.column_name, f.constraint_name, t.owner
from all_cons_columns t, all_constraints f
where f.r_owner = t.owner
and f.r_constraint_name = t.constraint_name

If you look for a specific table you can perform you can add the filter:

and  f.table_name = 'sua_tabela'
    
20.01.2016 / 13:25