Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2003
    Posts
    8

    Unanswered: Parent table, which children

    When I have a parent table,

    how can i determine all children tables ?
    Is there a query to generate this info ?

  2. #2
    Join Date
    Oct 2003
    Posts
    5

    Re: Parent table, which children

    select table_name from all_constraints where r_constraint_name in
    (select constraint_name from all_constraints
    where table_name ='PARENT_TABLE_NAME'
    and constraint_type in ('P','U'))

  3. #3
    Join Date
    Oct 2002
    Location
    Plymouth UK
    Posts
    116
    If you need to know the tables and the columns involved, this should do it.

    Code:
    SELECT a.table_name parent_table,
           a.column_name parent_column,
           b.table_name child_table,
           b.column_name child_column,
           b.constraint_name
    FROM user_cons_columns a,
         user_cons_columns b,
         user_constraints c
    WHERE a.table_name ='YOUR TABLENAME' and
          a.constraint_name = c.r_constraint_name and
          b.constraint_name =c.constraint_name;

  4. #4
    Join Date
    Sep 2003
    Posts
    8

    Loop

    Is it possible to build this in a loop ?

    So that i can see the next child table

    For instance if I have this model :

    Table XAT001
    _____________________|______________________
    | | |
    XAT002 Table XAT002 XAT003
    | | |
    | | |
    XAT003 Table XAT005 XAT006
    |
    |
    XAT007
    |
    ______|_____
    | |
    XAT008 XAT009

    and so on ...!

  5. #5
    Join Date
    Nov 2003
    Location
    Bangalore, INDIA
    Posts
    333

    Re: Loop

    Hi,

    You can Use Hierachial SELECT to build the tree structure depicting Parent & Child Tables.
    SATHISH .

  6. #6
    Join Date
    Sep 2003
    Posts
    8

    Can u explain this a bit more ?

    Can u give me some more info or an example ?

    Thanks

Posting Permissions

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