View previous topic :: View next topic
|
Author |
Message |
meenakshi_forum Warnings : 1 Active User
Joined: 27 May 2008 Posts: 121 Location: India
|
|
|
|
Hi,
Can anyone give me the syntax to find primary key of a table?
Thanks. |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Use the forum SEARCH. There is posted info on how to identify the primary key. |
|
Back to top |
|
|
Ragav86
New User
Joined: 27 Jan 2010 Posts: 37 Location: chennai
|
|
|
|
Use this
select name
from sysibm.syscolumns
where tbname = 'xxxx'
and tbcreator ='yyyyy'
and keyseq>0
order by keyseq; |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Why do you believe this will identify the primary key? |
|
Back to top |
|
|
Ragav86
New User
Joined: 27 Jan 2010 Posts: 37 Location: chennai
|
|
|
|
syscolumns will have the information about the primary keys
so i am using this query to get the primary key information.
please en light me if i am wrong.... |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
Back to top |
|
|
tomehta
New User
Joined: 18 Aug 2008 Posts: 98 Location: India
|
|
|
|
Hi Dick
Quote: |
Not necessarily wrong |
out of curosity, in which case the KEYSEQ will have a value other than zero, but still the corresponding colum will not be a part of key.
Regards |
|
Back to top |
|
|
dick scherrer
Moderator Emeritus
Joined: 23 Nov 2006 Posts: 19244 Location: Inside the Matrix
|
|
|
|
Hello,
Quote: |
in which case the KEYSEQ will have a value other than zero |
You misunderstand. . . I'll try again.
The values returned in your query will be parts of the key, but this is not the most complete info available.
Suggest you look thru the 2 links posted to see the kind of info more often wanted than just some column names.
Also, the original request was to "to find primary key" which (i believe) would at least include the name of the index. . . |
|
Back to top |
|
|
Ragav86
New User
Joined: 27 Jan 2010 Posts: 37 Location: chennai
|
|
|
|
ya i got it thanks a lot..... |
|
Back to top |
|
|
|