Portal | Manuals | References | Downloads | Info | Programs | JCLs | Master the Mainframes
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist Usergroups Profile Log in to check your private messages Log in
 

 

To find out relationship among tables

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

New User


Joined: 19 Jan 2009
Posts: 59
Location: hyderabad

PostPosted: Mon Mar 12, 2012 6:33 pm    Post subject: To find out relationship among tables
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: 1754
Location: Bloomington, IL

PostPosted: Mon Mar 12, 2012 6:52 pm    Post subject:
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

Moderator


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

PostPosted: Mon Mar 12, 2012 10:09 pm    Post subject:
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: 59
Location: hyderabad

PostPosted: Wed Mar 14, 2012 4:21 pm    Post subject:
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    Post subject: To find out relationship among tables
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: 6967
Location: porcelain throne

PostPosted: Wed Mar 14, 2012 4:39 pm    Post subject: Re: To find out relationship among tables
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    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 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
No new posts SPUFI -- Joining 3 tables – data in... Sysaron DB2 2 Wed Mar 08, 2017 4:18 am
No new posts To know activities on db2 tables ashek15 DB2 4 Fri Mar 03, 2017 11:23 pm


Facebook
Back to Top
 
Mainframe Wiki | Forum Rules | Bookmarks | Subscriptions | FAQ | Tutorials | Contact Us