How do I know which tables have foreign keys on my table?

Is there a query that I can do to find which tables have foreign keys in a given table? Our DBA does not believe (or understands?) "ON DELETE CASCADE", so when I delete something from the table, I want to first make sure that I delete all dependent things first.

(Note: I do not need to programmatically look up tables, I can do this in SQL * Plus.)

+3
source share
2 answers
SELECT dc.constraint_name, dc.constraint_type, dc.owner, dc.table_name
FROM dba_cons_columns dcc 
JOIN dba_constraints dc ON (dcc.constraint_name = dc.r_constraint_name and dc.owner = dcc.owner)
WHERE dcc.owner = 'OWNER_NAME' and dcc.table_name = 'TABLE_NAME';
+2
source

Check all_constraintsand all_cons_columnsdictionaries.

+1
source

Source: https://habr.com/ru/post/1765117/


All Articles