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

How to find out the Parent Table of a Table in DB2


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

New User


Joined: 15 May 2006
Posts: 28

PostPosted: Tue Oct 10, 2006 5:17 pm
Reply with quote

Can anyone tell me how to find out a Parent Table of a table in DB2 without using any tools. May be thru some query or something else.
Please can anyone help me out. Will be very useful.

Thx
Back to top
View user's profile Send private message
MFRASHEED

Active User


Joined: 14 Jun 2005
Posts: 186
Location: USA

PostPosted: Tue Oct 10, 2006 8:16 pm
Reply with quote

Try this SQL:

Code:

SELECT *                     
FROM SYSIBM.SYSRELS         
                             
WHERE TBNAME = 'Table Name'   



In returned data column REFTBNAME is the parent table.
Back to top
View user's profile Send private message
prodigy

New User


Joined: 15 May 2006
Posts: 28

PostPosted: Wed Oct 11, 2006 11:28 am
Reply with quote

Thx mate... My id doesnt have enough previlege to even read from Catalog...wondering wat to do!!!!!!! icon_sad.gif
Back to top
View user's profile Send private message
surya_pathaus

Active User


Joined: 28 Aug 2006
Posts: 110

PostPosted: Wed Oct 11, 2006 5:29 pm
Reply with quote

Hi,

You can also check parent table via DDL of the child table.

Check the DDL foreign key. There parent table will be defined.
Back to top
View user's profile Send private message
prodigy

New User


Joined: 15 May 2006
Posts: 28

PostPosted: Thu Oct 12, 2006 12:32 pm
Reply with quote

Where can i see the DDL for a child table.??? icon_sad.gif
Back to top
View user's profile Send private message
surya_pathaus

Active User


Joined: 28 Aug 2006
Posts: 110

PostPosted: Thu Oct 12, 2006 3:43 pm
Reply with quote

Hi,

In File Aid, go to 3.4 "Object List Processing" .
Give details of table then give the command GD at "CMD" column.

In Platinum, select the table and give DDL at the "CMD" column.
Back to top
View user's profile Send private message
prashanth1

New User


Joined: 27 Sep 2006
Posts: 47
Location: Hyderabad

PostPosted: Thu Oct 12, 2006 4:54 pm
Reply with quote

Try with the following Query


SELECT * FROM SYSIBM.SYSRELS;

It will display all the fields alongwith CREATOR, TBNAME, RELNAME, REFTBNAME, REFTBCREATOR, COLCOUNT

1) CREATOR : Name of the Owner of Child table

2) TBNAME : Child Table Name

3) RELNAME : Here it displays the column name ( defined as Foreign key in Child table and Primary key in Parent table)

4) REFTBNAME : Parent table name

5) REFTBCREATOR : Owner for the parent table


Pls Correct Me, If I wrong
Back to top
View user's profile Send private message
prodigy

New User


Joined: 15 May 2006
Posts: 28

PostPosted: Mon Oct 16, 2006 4:37 pm
Reply with quote

Thx Guys.... Thx a lot for ur replies
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 Load new table with Old unload - DB2 DB2 6
No new posts Pulling a fixed number of records fro... DB2 2
No new posts To find whether record count are true... DFSORT/ICETOOL 6
No new posts Multiple table unload using INZUTILB DB2 2
No new posts Check data with Exception Table DB2 0
Search our Forums:

Back to Top