User Tools

Site Tools



Oracle - List Foreign Keys

List Foreign Keys that targets specific table

SELECT a.TABLE_NAME, a.column_name, a.constraint_name, c.owner, 
       -- referenced pk
       c.r_owner, c_pk.TABLE_NAME r_table_name, c_pk.constraint_name r_pk
  FROM all_cons_columns a
  JOIN all_constraints c ON a.owner = c.owner
                        AND a.constraint_name = c.constraint_name
  JOIN all_constraints c_pk ON c.r_owner = c_pk.owner
                           AND c.r_constraint_name = c_pk.constraint_name
 WHERE c.constraint_type = 'R'
   AND c_pk.TABLE_NAME = :TableName
technical_notes/public/oracle-list-foreign-keys.txt · Last modified: 2015/01/12 18:54 by Fabien Arcellier