How to find all child tables

Hi,
I have a set of tables that are in multi level hierarchy.
Here is the example.
Table1 (id is primary key)
Table2 (id,loc is primary key. and id is refering to table1.id) Table3(id,name is primary key and id is refering to table1)
Table 4(emp_id,group,name,loc_grp is PK. emp_id and loc_grp is refering to table2) Table5(std_id,name,dpt,sal is pk and std_id,name is refering to table3)
Now, I want to get all tables and their columns that are refering to Table1.id. In this example, it should return table2, table3,table4 and table5 along with their columns.
some thing like this.
Table_name Column_name
Table2 id
Table3 id
Table4 emp_id
Table5 std_id
Please suggest how to get this.

HI ,please try this one .
SELECT a.table_name, c.column_name, b.table_name AS child_table,
       d.column_name, b.r_constraint_name
  FROM user_constraints a,
       user_constraints b,
       user_ind_columns c,
       user_cons_columns d
WHERE a.constraint_type = 'P'
   AND a.constraint_name = b.r_constraint_name
   AND b.constraint_type = 'R'
   AND a.table_name = c.table_name
   AND a.constraint_name = c.index_name
   AND b.constraint_name = d.constraint_name
   AND a.table_name = '<TABLE_NAME>' ;thanks,
P Prakash

Similar Messages

  • How to find all the tables associated for a particular transaction

    Hi-
    May I know how to find all the tables, related(foreign key) tables for a transaction within SAP GUI?
    Up to my technical knowledge, this can be achieved by looking database diagrams from DB level. But that would be for entire database as a whole. What I'm expecting is to see transaction level relative tables that too from SAP GUI. Please share the possibilities if any.
    Regards
    Sekhar

    Dear Micky Oestreich
    May be we possess expertise or high level experience, it should not show up in our way of communication. Every professional starts with the basic stuff to learn. When the question is raised in such minimum polite way, the same level of courtesy is expected in return. If you felt my question was basic, you might have refused it gently. If you are in good mood or bad mood it doesn't matters.
    Hi Vengal Rao
    Thanks for your response. It helped me.
    Regards
    Sekhar

  • Finding all child tables

    How can i find all the the child tables of a table? Is there an SQL query in Oracle by which i could get this info?

    Hi,
    select table_name, constraint_type
      from user_constraints
    where R_CONSTRAINT_NAME=  (select constraint_name
                                                         from user_constraints
                                                     where table_name = 'PARENT' and constraint_type = 'P')
       and constraint_type = 'R';Regards

  • How to find out child tables

    Hi,
    My data base Table master_accouts contain some of child tables. I would like to
    Know How can i findout How many tables/what r those tables. Please guide me.
    warm regards,
    Venkat.

    Hi,
    My data base Table master_accouts contain some of child tables. Could you please give more information on what you want ?
    If you want to find the constraints then yo can use ALL_CONS_COLUMNS view to get the constraints.
    Thanks

  • How to find  out child tables given a parent table /parent's constraint_nam

    Hi
    I need to disable a primary key but is not able to becoz of referential constraint
    select child_constraint.table_name, child_constraint.constraint_name, child_detail.column_name
    from user_cons_columns child_detail
    join user_constraints child_constraint
    on child_detail.constraint_name = child_detail.constraint_name
    and child_detail.owner = child_detail.owner
    and child_detail.table_name= child_detail.table_name
    where child_constraint.constraint_type='R'
    and child_constraint.status='ENABLED'
    and child_constraint.r_constraint_name='SUBSCRIBER_PK';
    and child_detail.table_name='ADDRESS_BOOK_GROUP';
    Given a table name how would I know all the child tables and the child tables' columns referencing the parent keys?
    thanks

    thanks for the reply
    while the first query is correct
    select child_constraints.table_name child_table_name, child_detail.constraint_name child_constraint_name
    , child_detail.column_name child_column_name, child_constraints.constraint_type child_constraint_type
    , child_constraints.status, parent_constraints.table_name parent_table_name, parent_detail.column_name parent_column_name
    , parent_constraints.constraint_name parent_constraint_name
    , parent_constraints.status parent_constraint_status from
    user_cons_columns child_detail
    join user_constraints child_constraints
    on child_detail.constraint_name=child_constraints.constraint_name
    and child_detail.owner=child_constraints.owner
    and child_detail.table_name=child_constraints.table_name
    join user_constraints parent_constraints
    on parent_constraints.constraint_name=child_constraints.r_constraint_name
    join user_cons_columns parent_detail
    on parent_detail.constraint_name=parent_constraints.constraint_name
    and parent_detail.owner=parent_constraints.owner
    and parent_detail.table_name=parent_constraints.table_name
    where
    child_constraints.r_constraint_name in (
    select constraint_name from user_constraints parent_constraint
    where parent_constraint.constraint_type='P'
    and parent_constraint.status='ENABLED'
    and parent_constraint.table_name='SUBSCRIBER'
    and child_constraints.constraint_type='R'
    and parent_constraints.constraint_type='P'
    --and child_constraints.status='ENABLED'
    order by child_constraints.table_name
    , child_detail.position
    the second query return a lots of garbage why is this so?
    select child_constraints.table_name child_table_name, child_detail.constraint_name child_constraint_name
    , child_detail.column_name child_column_name, child_constraints.constraint_type child_constraint_type
    , child_constraints.status, parent_constraints.table_name parent_table_name, parent_detail.column_name parent_column_name
    , parent_constraints.constraint_name parent_constraint_name
    , parent_constraints.status parent_constraint_status from
    user_cons_columns child_detail
    join user_constraints child_constraints
    on child_detail.constraint_name=child_constraints.constraint_name
    and child_detail.owner=child_constraints.owner
    and child_detail.table_name=child_constraints.table_name
    join user_constraints parent_constraints
    on parent_constraints.constraint_name=child_constraints.r_constraint_name
    join user_cons_columns parent_detail
    on parent_detail.constraint_name=parent_constraints.constraint_name
    and parent_detail.owner=parent_constraints.owner
    and parent_detail.table_name=parent_constraints.table_name
    where
    child_constraints.constraint_type='R'
    and parent_constraints.constraint_type='P'
    --and child_constraints.status='ENABLED'
    order by child_constraints.table_name
    , child_detail.position
    thanks

  • How to find all the table used in a report

    Hi Expert ,
                    Is there is any program  to find out all the tables which  are used in a perticular report .
    Thanks in advance
    Tarak

    Well, so far Viquar Iqbal has given the only really correct answer - use SQL trace.  The reason the others are incomplete, is because they don't consider that a report might call a function module or a class method that accesses a table.  In fact, for many applications this is exactly what happens - db accesses are abstracted away from the main program.
    The other alternative to SQL trace is to use Run Time Analysis.  The advantage of SQL trace is that it shows the tables hit in order.
    matt

  • How to find All backup table in the d/b with different suffix?

    I need to find out all backup tables where table having suffix like BKUP and some dates in number.
    For e.g.:
    WX_ACCOUNT_YEAR_FUND_BKUP
    WX_ACTUALS_CATEGORY_D_APR05
    WX_ACTUALS_F_APR05
    WX_ACTUALS_F_BACKUP_APR05
    WX_ACTUALS_F_JAN_17_2006
    WX_ACTUALS_F_JUL05
    WX_CHECK_BOOK_HEADER_D_010306
    WX_DIMENSION_ACTUALS_OLD
    WX_DIMENSION_ACTUALS_OLD_APR05
    W_ORG_DSXBKP09292005
    Is there any way to find such tables by using SQL query.

    WITH T
    as
    select 'WX_ACCOUNT_YEAR_FUND_BKUP' table_name from dual
    union all
    select 'WX_ACTUALS_CATEGORY_D_APR05' from dual
    union all
    select 'WX_ACTUALS_F_APR05' from dual
    union all
    select 'WX_ACTUALS_F_BACKUP_APR05' from dual
    union all
    select 'WX_ACTUALS_F_JAN_17_2006' from dual
    union all
    select 'WX_ACTUALS_F_JUL05 ' from dual
    union all
    select 'WX_CHECK_BOOK_HEADER_D_010306' from dual
    union all
    select 'WX_DIMENSION_ACTUALS_OLD' from dual
    union all
    select 'WX_DIMENSION_ACTUALS_OLD_APR05' from dual
    union all
    select 'W_ORG_DSXBKP09292005' from dual
    union all
    select 'W_ORG_DSXBKP' from dual
    select table_name from t
    where regexp_like(table_name,'[[:digit:]]$')
    or ( table_name  like '%BKUP' or table_name  like '%OLD')I have considered the table names ending with OLD also as backup tables. If this is not a backup table then remove the condition from the where clause
    Regards,
    Mohana

  • Query ---  to find all child tables for a master table

    Suppose i have a table master .
    I want to know all tables which are child tables for this master table .
    In other words i want to know all those table names which have foreign key constraint for the master table .
    regards
    shubha

    You may want to join on the owner in case you have multiple schemas with same table names and same primary key names
    SELECT c.table_nameFROM all_constraints c, all_constraints p
    WHERE c.constraint_type = 'R'
    AND c.r_constraint_name = p.constraint_name
    AND p.constraint_type = 'P'
    AND c.owner = p.owner
    AND p.table_name = '&YOUR_MASTER_TABLE'

  • Find all child tables - validate sql

    I have a table (tabA), In tabA i have a column (id) which is part of primary key
    Question: I need to know all the tables which have foreign keys refererring to tabA.id
    I used the following sql, please let me know if this is correct:
    select table_name
      from dba_constraints
    where (r_constraint_name) in ( select constraint_name
                                      from dba_constraints
                                     where table_name = 'tabA'
                                       and constraint_type in ( 'P', 'U' ) );

    On 11.2 you could try recursive subquery factoring:
    select *
    from ( with the_constraints( table_name
                               , constraint_name
                               , r_constraint_name
                               , lvl
           as ( select a.table_name
                ,      a.constraint_name
                ,      a.r_constraint_name
                ,      1 lvl
                from   all_constraints a
                where  a.table_name  = 'tabA'
                and    a.constraint_type = 'P'
                union all
                select c.table_name
                ,      nvl(( select constraint_name
                             from   all_constraints
                             where  table_name = c.table_name
                             and    constraint_type = 'P'
                          , c.constraint_name
                ,      c.r_constraint_name
                ,      lvl+1
                from   the_constraints p,
                       all_constraints c
                where  p.constraint_name = c.r_constraint_name
                and    c.constraint_type = 'R'
           search depth first by table_name set seq
           cycle table_name set is_cycle to 1 default 0
           select rownum rn
           ,      lpad('>', (lvl-1)*2, '-')||table_name relation
           ,      c.*
           from   the_constraints c
    order by rn desc;

  • How to find all Custom tables (transp) that have a custom transaction code?

    My client has asked us to provide a list of all Z (custom) tables and the associated transaction codes for maintaining them.
    I know I can manually do this with a Z* search in se11 and then do a where used on each table to find out if a view (transaction code) exists for the table - BUT THIS WOULD TAKE HOURS IF NOT DAYS TO DO AND BE LIABLE FOR HUMAN ERROR.
    Does anyone know the way we could code a search for this information (ABAP) and know what tables to use?
    Thanks.
    Scott

    Hi
    You can search in table TSTCP for custom tables that have a maintainance view and a transaction associated, which is a call to SM30. To do this, just select the table with TCODE starting with 'Z' and PARAM starting with '/*SM30'.
    But you can also have some Z tables updated by an module pool program. This is more complex to find, because you don't know if you simply have the field used in the screen for some other use in a transaction, or if it is in that screen just to update the table. In this case, you need to analyze each screen.But I hope the first tip help you to solve your problem.

  • How to find all the tables by feild value in oracle

    Hi ...
    I have a requirement to find the tables in a particular schema(suppose DEMO) by Field value..
    Ex:
    suppose in a  schema called DEMO  i have the tables.......T1,T2,T3,T4,T5..
    all the above tables have the name column..
    now i wan to know the tables whose column(name) have value as rajani.......
    pls help.........
    thank you
    .+

    Solutions from previous requests for the same...
    michaels>  var val varchar2(5)
    michaels>  exec :val := 'as'
    PL/SQL procedure successfully completed.
    michaels>  select distinct substr (:val, 1, 11) "Searchword",
                    substr (table_name, 1, 14) "Table",
                    substr (t.column_value.getstringval (), 1, 50) "Column/Value"
               from cols,
                    table
                       (xmlsequence
                           (dbms_xmlgen.getxmltype ('select ' || column_name
                                                    || ' from ' || table_name
                                                    || ' where upper('
                                                    || column_name
                                                    || ') like upper(''%' || :val
                                                    || '%'')'
                                                   ).extract ('ROWSET/ROW/*')
                       ) t
    --        where table_name in ('EMPLOYEES', 'JOB_HISTORY', 'DEPARTMENTS')
           order by "Table"or
    11g upwards
    SQL> select table_name,
           column_name,
           :search_string search_string,
           result
      from (select column_name,
                   table_name,
                   'ora:view("' || table_name || '")/ROW/' || column_name || '[ora:contains(text(),"%' || :search_string || '%") > 0]' str
              from cols
             where table_name in ('EMP', 'DEPT')),
           xmltable (str columns result varchar2(10) path '.')
    TABLE_NAME                     COLUMN_NAME                    SEARCH_STRING                    RESULT   
    DEPT                           DNAME                          es                               RESEARCH 
    EMP                            ENAME                          es                               JAMES    
    EMP                            JOB                            es                               SALESMAN 
    EMP                            JOB                            es                               SALESMAN 
    4 rows selected.

  • How to find all open POs and there SUM

    How to find all open POs and there SUM
    Please help.
    Thanks,
    vihar9

    Have you tried looking at the tables, standard reports, or the PO display transaction?  Have you asked your functional analyst or development team lead? This is not a forum to post a requirement and get your job done for you...

  • How to find out the tables from extract structures

    Hi All,
    As I know my data sources are 2lis_04_p_matnr,2lis_04_p_comp,2lis_04_p_arbpl.
    How to find out the tables concerned with the fields in the extract structure.
    Thanks

    Pl check this link:
    http://help.sap.com/saphelp_nw2004s/helpdata/en/29/79eb3cad744026e10000000a11405a/frameset.htm
    OR navigate to: help.sap.com - netweaver - bi content - supply chain - look for your application area and the extractor and you will see the source tables and fields.
    Ravi Thothadri

  • How to find out the table name

    hi,
    how to find out the table name in which the data from a particular structure in a particular screen is saved,
    please tell me the procedure to find out the table name for saving the structure data that is inputted at runtime.
    Thanks,
    chinnu

    Hi Chinnu,
    Below are the tables that are referred to find out the table names
    DD02L Table contains the SAP Tables.
    DD02T Table contains the SAP Table Texts.
    DD01L Table contains the Domains
    DD01T Table contains the Domain Texts.
    DD03L Table contains the Table Fields.
    DD03T Table contains the Table Field Texts. (Language Dependent)
    DD04L Table contains the Data Elements.
    DD04T Table contains the Data Element Texts.
    DD05s Table contains the Foreign Key Fields
    last words with L and T only. L->Database Fetch T-> Text
    And the procedure to retrive the table name is as follows
    1. Go to se11
    2. Enter table name DD03T and execute
    3. In the next screen you can find Tables, fields, test etc. there you can enter the field name in the fields 
      and execute.
    4. you can get all tables which contains the field.
    I hope this will solve your problem
    Regards,
    Chandru

  • How to find out the tables related to CRM datasources?

    How to find out the tables related to CRM datasources? For example, the table related to 0CRM_OPPT_H.
    Regards,
    R.Ravi

    Hi Ravi,
    To find out all tables used go into the CRM source system to transaction RSA3 and prepare the selections for extraction of your datasource.
    In a parallel session execute transaction ST05 and press the button 'Activate Trace'
    Go back to the extracor checker and execute the extraction.
    Switch sessions and subsequently 'Deactivate Trace' and 'Display Trace'.
    This will list all tables used.
    regards,
    Olav

Maybe you are looking for