Find the tables referencing a specific table by foreign key


SELECT a.owner || '.' || a.table_name "Referenced Table", 
 b.owner || '.' || b.table_name "Referenced by", 
 b.constraint_name "Foreign Key", 
 b.constraint_type 
FROM all_constraints a, 
 all_constraints b 
WHERE b.constraint_type = 'R' 
AND a.constraint_name = b.r_constraint_name 
AND a.table_name = 'TABLE1' -- Table name
AND a.owner = b.r_owner
ORDER BY 1;

Source: http://www.databasejournal.com/features/oracle/article.php/3665591/Finding-Foreign-Key-Constraints-in-Oracle.htm

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s