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

What are the different ways to find out the primary key


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

New User


Joined: 11 Oct 2005
Posts: 62
Location: India

PostPosted: Thu Jan 18, 2007 11:09 am
Reply with quote

Hi All

What are the different ways to find out the primary key on a table?

Thanks in adv
sri
Back to top
View user's profile Send private message
rajandhla

Active User


Joined: 18 Oct 2005
Posts: 182
Location: Luton UK

PostPosted: Thu Jan 18, 2007 12:01 pm
Reply with quote

Go to the table schema and find out which key is defined as primary or forgein key..etc

else

find the indexed keys on the table and check whether it is defined as unique key or duplicate key. If it is unique it can used as PK..

regards
JR
Back to top
View user's profile Send private message
Garpen

New User


Joined: 03 Jan 2007
Posts: 14
Location: Sweden

PostPosted: Thu Jan 18, 2007 1:06 pm
Reply with quote

Hi
For z/os, check UNIQUERULE i SYSINDEXES, it should be a P
Back to top
View user's profile Send private message
DavidatK

Active Member


Joined: 22 Nov 2005
Posts: 700
Location: Troy, Michigan USA

PostPosted: Fri Jan 19, 2007 2:24 am
Reply with quote

Try this query:

Code:

SELECT IX.TBNAME,                     
       KEYS.IXNAME,                   
       IX.UNIQUERULE,                 
       KEYS.COLNAME,                   
       KEYS.COLNO,                     
       KEYS.COLSEQ                     
  FROM SYSIBM.SYSINDEXES    IX,       
       SYSIBM.SYSKEYS       KEYS       
 WHERE IX.TBNAME          = 'YOUR_TABLE'
   AND KEYS.IXNAME        = IX.NAME   
 ORDER BY IX.TBNAME,                   
          KEYS.IXNAME,                 
          KEYS.COLSEQ                 
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 To find whether record count are true... DFSORT/ICETOOL 6
No new posts Query on edit primary command CLIST & REXX 5
No new posts Query on edit primary command CLIST & REXX 1
No new posts Find the size of a PS file before rea... COBOL Programming 13
No new posts Cobol prog to put an indicator on the... JCL & VSAM 1
Search our Forums:

Back to Top