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
 

 

What are the different ways to find out the primary key

 
Post new topic   Reply to topic    IBMMAINFRAMES.com Support Forums -> DB2
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    Post subject: What are the different ways to find out the primary key
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    Post subject: Re: Primary Key on a DB2 table
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    Post subject: Re: Primary Key on a DB2 table
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    Post subject: Re: What are the different ways to find out the primary key
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    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 find particular member name in PDS us... ravi243 CLIST & REXX 10 Mon Dec 19, 2016 6:44 pm
No new posts How to find the first monday of the w... abdulrafi COBOL Programming 10 Fri Nov 25, 2016 3:24 pm
No new posts Find out a active PGM jpsager JCL & VSAM 10 Fri Oct 07, 2016 4:32 pm
No new posts How to find a CICS resource used in C... Arunkumar Chandrasekaran CICS 8 Thu Sep 29, 2016 1:45 pm
No new posts how to find clist's or view library Andrew Hsia CLIST & REXX 4 Tue Jun 28, 2016 6:07 pm


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