469,366 Members | 2,227 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,366 developers. It's quick & easy.

How to find the primary key of a particular table?

hi,

i am working on db2.
how can i check for a particular table,the primary key of that table.
for eg. in table REGISTRATION their are around 20 columns. how to check which is the primary key of that table
Feb 1 '11 #1

✓ answered by deepak n

Try the following query

SELECT sc.name
FROM SYSIBM.SYSCOLUMNS SC
WHERE SC.TBNAME = 'REGISTRATION'
AND sc.identity ='N'
AND sc.tbcreator=schemaname
AND sc.keyseq=1

2 18840
Try the following query

SELECT sc.name
FROM SYSIBM.SYSCOLUMNS SC
WHERE SC.TBNAME = 'REGISTRATION'
AND sc.identity ='N'
AND sc.tbcreator=schemaname
AND sc.keyseq=1
Feb 1 '11 #2
It worked.

Thank you deepak
Feb 1 '11 #3

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

1 post views Thread by JJ | last post: by
3 posts views Thread by bikkaran | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
1 post views Thread by Marylou17 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.