View previous topic :: View next topic
|
Author |
Message |
prodigy
New User
Joined: 15 May 2006 Posts: 28
|
|
|
|
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 |
|
|
MFRASHEED
Active User
Joined: 14 Jun 2005 Posts: 186 Location: USA
|
|
|
|
Try this SQL:
Code: |
SELECT *
FROM SYSIBM.SYSRELS
WHERE TBNAME = 'Table Name'
|
In returned data column REFTBNAME is the parent table. |
|
Back to top |
|
|
prodigy
New User
Joined: 15 May 2006 Posts: 28
|
|
|
|
Thx mate... My id doesnt have enough previlege to even read from Catalog...wondering wat to do!!!!!!! |
|
Back to top |
|
|
surya_pathaus
Active User
Joined: 28 Aug 2006 Posts: 110
|
|
|
|
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 |
|
|
prodigy
New User
Joined: 15 May 2006 Posts: 28
|
|
|
|
Where can i see the DDL for a child table.??? |
|
Back to top |
|
|
surya_pathaus
Active User
Joined: 28 Aug 2006 Posts: 110
|
|
|
|
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 |
|
|
prashanth1
New User
Joined: 27 Sep 2006 Posts: 47 Location: Hyderabad
|
|
|
|
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 |
|
|
prodigy
New User
Joined: 15 May 2006 Posts: 28
|
|
|
|
Thx Guys.... Thx a lot for ur replies |
|
Back to top |
|
|
|