Portal | Manuals | References | Downloads | Info | Programs | JCLs | Mainframe wiki | Quick Ref
IBM Mainframe Computers Forums Index
 
Register
 
IBM Mainframe Computers Forums Index Mainframe: Search IBM Mainframe Forum: FAQ Memberlist 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 Command to find TMEMBER name for a TPIPE Siva NKK Kothamasu IMS DB/DC 0 Wed Aug 16, 2017 6:08 pm
No new posts find RACF group for access to spooled... jzhardy JCL & VSAM 1 Mon May 08, 2017 11:46 am
No new posts To find out size allocated to a seque... ashek15 JCL & VSAM 15 Thu Apr 27, 2017 9:42 am
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

Facebook
Back to Top
 
Job Vacancies | Forum Rules | Bookmarks | Subscriptions | FAQ | Polls | Contact Us