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 View Bookmarks
All times are GMT + 6 Hours
Forum Index -> DB2

 


Similar Topics
Topic Forum Replies
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Need to fetch data from so many DB2 t... DB2 9
No new posts Find the occurrence of Key Field (Par... DFSORT/ICETOOL 6
No new posts Find a record count/numeric is multip... COBOL Programming 1
Search our Forums:

Back to Top