查询外键 反查哪些表用到当前表作为外键

Select  a.constraint_name,
               b.table_name,
               b.column_name,
               a.r_constraint_name,
               a.table_name,
               c.table_name
          From user_constraints a, user_cons_columns b,user_constraints c
         Where a.constraint_type = 'R'
           And c.constraint_name = b.constraint_name
           and a.r_constraint_name = c.constraint_name
           and c.table_name like 'table_name'

B表中的列c1是A表和C表的外键,table_name的参数值为B。查询的结果为A,C

你可能感兴趣的:(oracle)