IBM Mainframe Forum Index
 
Log In
 
IBM Mainframe Forum Index Mainframe: Search IBM Mainframe Forum: FAQ Register
 

How to find out the relationship between two tables.


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
View previous topic :: View next topic  
Author Message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Hyderabad

PostPosted: Fri Dec 01, 2006 4:38 pm
Reply with quote

How to find out the relationship between two tables. I tried by SYSIBM.SYSRELS, but there is only relation name,could not find any common column for two tables.

Could any one suggest me how to proceed?

thank you,
Mahi
Back to top
View user's profile Send private message
chettiyar
Currently Banned

New User


Joined: 27 Sep 2006
Posts: 6
Location: india,kerala

PostPosted: Fri Dec 01, 2006 6:54 pm
Reply with quote

SYSIBM.SYSCOLUMNS identifies columns of a parent key in column KEYSEQ; a nonzero value indicates the place of a column in the parent key.



Code:
SELECT TBCREATOR, TBNAME, NAME, KEYSEQ
FROM SYSIBM.SYSCOLUMNS
WHERE TBCREATOR = 'creater id'
AND TBNAME = 'table-name'
AND KEYSEQ > 0
ORDER BY KEYSEQ;


To find out the foreign key of a DB2 table from SYSIBM.

Code:
SELECT TBNAME, COLNAME, COLNO, CREATOR
FROM SYSIBM.SYSFOREIGNKEYS
WHERE TBNAME = 'table-name';
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Fri Dec 01, 2006 11:18 pm
Reply with quote

One more way to do the same is by PLATINUM utility:

From main menu select (1 RC/Query ), next screen enter table name in item name and select (RI - Ref.Integrity). Takes you of this menu and rest is self explanatory.

Code:

 RQRIM  r11    ---- RC/Q Referential Integrity Main Menu ----- 12-01-2006 11:43
 COMMAND ===>                                                                   
                                                                               
  DB2 Object ===> RI                   Option ===>                             
   Item Name ===> TABLNAME           Creator ===> *        Where => N         
   Qualifier ===> *                   Grantor ===> *                           
 Loc: LOCAL --- SSID: DB2S ----------XXXX ----                           
    Referential Integrity Options:                                             
                                                                               
            L = List                        FK = Foreign Key Columns           
                                                                               
            P = Parent Relationships        AK = All Key Columns               
                                                                               
            C = Child Relationships          T = Check Pending/Tables           
                                                                               
            A = All Relationships           TS = Check Pending/Tablespaces     
                                                                               
           PK = Primary Key Columns         SS = Spaceset                       
                                                                               
                                                                               
                                                                               
                                                                               
Back to top
View user's profile Send private message
View previous topic : : View next topic  
Post new topic   Reply to topic All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts Question regarding ISPF tables with T... TSO/ISPF 11
No new posts To join 2 tables and to join 3rd tabl... DB2 8
No new posts sort to find out the char which repea... Mainframe Interview Questions 10
No new posts Compare 2 alphabets in a REXX and fin... CLIST & REXX 2
No new posts To find whether record count are true... DFSORT/ICETOOL 6
Search our Forums:


Back to Top