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

To find out relationship among tables


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

New User


Joined: 19 Jan 2009
Posts: 63
Location: hyderabad

PostPosted: Mon Mar 12, 2012 6:33 pm
Reply with quote

Hi, Can anyone help me to find out a way to check the relationship between tables in mainframes. Suppose i have a table "x" with a column name "x_id".
I want to check if any other table have the same column or any kind of relationship exists between these 2. (assuming table qualifiers are same, ie
abc.X, abc.Y, abc.Z etc where X,Y,Z are the table names. i am using DB2)
Back to top
View user's profile Send private message
Akatsukami

Global Moderator


Joined: 03 Oct 2009
Posts: 1788
Location: Bloomington, IL

PostPosted: Mon Mar 12, 2012 6:52 pm
Reply with quote

Code:
SELECT SUBSTR(TBNAME,1,18) AS TABLE FROM SYSIBM.SYSCOLUMNS
WHERE NAME = 'X_ID'                                         
ORDER BY TABLE     
Back to top
View user's profile Send private message
Pandora-Box

Global Moderator


Joined: 07 Sep 2006
Posts: 1592
Location: Andromeda Galaxy

PostPosted: Mon Mar 12, 2012 10:09 pm
Reply with quote

If your shop has DB2 admin tools you can check for relationship among tables
Back to top
View user's profile Send private message
rikdeb

New User


Joined: 19 Jan 2009
Posts: 63
Location: hyderabad

PostPosted: Wed Mar 14, 2012 4:21 pm
Reply with quote

thanks the above query worked.!!!......
Back to top
View user's profile Send private message
satyapn9

New User


Joined: 08 Oct 2010
Posts: 27
Location: India

PostPosted: Wed Mar 14, 2012 4:28 pm
Reply with quote

Hi, You can also try this query which is similar to the above:

SELECT * FROM SYSIBM.SYSCOLUMNS WHERE
NAME = 'XXXXX' AND TBCREATOR = 'DB2PROD' AND TBNAME LIKE 'YYYY%'

Here NAME is the COLUMN Name
and TBCREATOR is the HIGH Level Qualifier of the table
and TBNAME is the Table Name
Back to top
View user's profile Send private message
dbzTHEdinosauer

Global Moderator


Joined: 20 Oct 2006
Posts: 6966
Location: porcelain throne

PostPosted: Wed Mar 14, 2012 4:39 pm
Reply with quote

satyapn9 wrote:
Hi, You can also try this query which is similar to the above:

SELECT * FROM SYSIBM.SYSCOLUMNS WHERE
NAME = 'XXXXX' AND TBCREATOR = 'DB2PROD' AND TBNAME LIKE 'YYYY%'

Here NAME is the COLUMN Name
and TBCREATOR is the HIGH Level Qualifier of the table
and TBNAME is the Table Name


satyapn9,
welcome, you are todays' recipient of dbz's 'dumb-ass post of the day' award.

1. why select all columns, in this case 47 (db2 v10) when you really only want one? the table name?

2. why have WHERE clauses that look for specific table names,
when the only thing you know is the column name?

3. why did you not bother to read the request from the TS
and provide a solution?


For wasting forum space
and
revealing that you really have little to offer,
you are hereby awarded the DUMB-ASS POST OF THE DAY award
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