Kermit_ice_tea
Kermit_ice_tea

Reputation: 518

How to view the foreign keys relationships on a DB table in Oracle

I know that in order to view the uniqueness of a table you use something like this

set serveroutput on;
BEGIN
    <DB name>.show_uniqueness('BILL_BASE.<Table name>');
END;

and this gives you all unique constraints on the table you intend to modify.

My question is how to view all foreign keys associated with a table. Is there a query like the one above that i can use to view such information

Upvotes: 0

Views: 105

Answers (1)

Rene
Rene

Reputation: 10541

You can query user_constraints view to list all constraints defined on your tables. Foreign key constraints have type R:

select constraint_name
      ,table_name
  from user_constraints
 where constraint_type = 'R'

Column R_CONSTRAINT_NAME will give you the primary key constraint for the other table. Using the same view but now for the PK constraint will give you information about the related table.

Upvotes: 1

Related Questions