Results 1 to 2 of 2
  1. #1
    Join Date
    Jan 2006
    Posts
    3

    Unanswered: Foreign Keys dependencies

    want to know how to obtain the relationships of foreing keys when they have diferent names in diferent tables using SQL querys from VB.net in ORACLE.

    Example:

    Table Person
    ------------
    IDPerson
    Name
    Address


    Table Customer
    --------------
    IDCustomer
    .
    .
    .


    Table Employee
    ---------------
    IDEmployee
    .
    .
    .


    The dependencies are:

    IDPerson--->IDCustomer
    IDPerson--->IDEmployee

  2. #2
    Join Date
    Apr 2003
    Location
    Greenville, SC (USA)
    Posts
    1,155
    Here's an example of a sql script (from sqlplus) ... just fill in the table_name
    and it tells you what the child tables are

    SELECT table_name,constraint_name,STATUS,delete_rule from user_constraints a where
    r_constraint_name = (select constraint_name from user_constraints
    where table_name = UPPER('&table_name') and constraint_type = 'P')
    and constraint_type = 'R';

    or turn it around and enter the table_name to find out what the entered
    table is a child to.

    SELECT table_name,constraint_name from user_constraints a where
    constraint_name IN (select R_constraint_name from user_constraints
    where table_name = UPPER('&table_name') and constraint_type = 'R')
    and constraint_type = 'P';


    HTH
    Gregg

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •