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

Need info to find a primary key of a table


IBM Mainframe Forums -> DB2
Post new topic   Reply to topic
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
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

Superior Member


Joined: 14 Mar 2007
Posts: 10873
Location: italy

PostPosted: Wed Jun 13, 2007 3:20 pm
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
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
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 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