For a given table 'foo', I need a query to generate a set of tables that have foreign keys that point to foo. I'm using Oracle 10G.
select * from sys.foreign_keys If you want to search foreign keys created on a SQL table, you can use following SELECT command querying sys. foreign_keys system view on parent_object_id column value. On the other hand, if SQL programmer is dealing with SQL tables referring to a specific table, then sys.
This should work (or something close):
select table_name
from all_constraints
where constraint_type='R'
and r_constraint_name in
(select constraint_name
from all_constraints
where constraint_type in ('P','U')
and table_name='<your table here>');
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With