Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Profile Log in to check your private messages Log in
 
How to find out the relationship between two tables.

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
View previous topic :: :: View next topic  
Author Message
mahi

New User


Joined: 04 Apr 2006
Posts: 86
Location: Pune

PostPosted: Fri Dec 01, 2006 4:38 pm    Post subject: How to find out the relationship between two tables.
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    Post subject: Re: How to find out the relationship between two tables.
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    Post subject: Re: How to find out the relationship between two tables.
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    IBMMAINFRAMES.com Support Forums -> DB2 All times are GMT + 6 Hours
Page 1 of 1

 

Search our Forum:

Similar Topics
Topic Author Forum Replies Posted
No new posts Command to find TMEMBER name for a TPIPE Siva NKK Kothamasu IMS DB/DC 0 Wed Aug 16, 2017 6:08 pm
No new posts Identify top 30 big tables or indexes... ashek15 DB2 0 Fri Jun 16, 2017 10:01 am
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
No new posts Data replication from multiple Db2 ta... kishpra DB2 9 Mon Mar 27, 2017 9:58 pm

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us