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
 

 

Need info to find a primary key of a table

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

Active User


Joined: 13 Dec 2005
Posts: 154
Location: The Netherlands

PostPosted: Wed Jun 13, 2007 3:12 pm    Post subject: Need info to find a primary key of a table
Reply with quote

Hi All,

My requirement is to get the primary key and foriegn key info(if any). for a given table. I know this can be done by quering the system catalog tables but need the specific table name from which i can obtain the same. thanks in advance


Thamilzan.
Back to top
View user's profile Send private message

enrico-sorichetti

Global Moderator


Joined: 14 Mar 2007
Posts: 10232
Location: italy

PostPosted: Wed Jun 13, 2007 3:20 pm    Post subject: Re: Need info to find a primary key of a table
Reply with quote

Two queries
on SYSIBM.SYSKEYS and SYSIBM.SYSFOREIGNKEYS will provide You with the requested info

regards

e.s.
Back to top
View user's profile Send private message
SHAILESH OZA

New User


Joined: 10 Jun 2005
Posts: 21
Location: Mumbai

PostPosted: Tue Jun 26, 2007 3:18 pm    Post subject:
Reply with quote

Go to Spufi Choose option 5 platinum.
Back to top
View user's profile Send private message
vini_srcna

Active User


Joined: 26 May 2005
Posts: 178
Location: Copenhagen, Denmark

PostPosted: Thu Jun 28, 2007 10:12 am    Post subject:
Reply with quote

For Primary Key:

Query SYSIBM.SYSCOLUMNS for that table with KEYSEQ > 0

For Foriegn Key:

Query SYSIBM.SYSFORIEGNKEYS, SYSIBM.SYSRELS , SYSIBM.SYSKEYS
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 Data replication from multiple Db2 ta... kishpra DB2 1 Mon Mar 27, 2017 9:58 pm
No new posts how to send just 10 rows in a CICS sc... Megha Gupta CICS 5 Thu Feb 23, 2017 6:57 pm
No new posts Join of more than one table dibyendumandal11111 DB2 6 Mon Feb 13, 2017 11:36 pm
No new posts Need info with DBRC recovery ashek15 IMS DB/DC 0 Mon Jan 23, 2017 6:43 am
No new posts find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm


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