Query a Table's Foreign Key relationships

后端 未结 9 1875
旧时难觅i
旧时难觅i 2020-12-03 01:40

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.

9条回答
  •  我在风中等你
    2020-12-03 01:58

    select      acc.table_name, acc.constraint_name 
    from        all_cons_columns acc
    inner join all_constraints ac
        on acc.constraint_name = ac.constraint_name
    where       ac.r_constraint_name in (
        select  constraint_name
        from    all_constraints
        where   table_name='yourTable'
        );
    

提交回复
热议问题