If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > Informix > how to get primary key ?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 09-17-07, 09:41
meiwen meiwen is offline
Registered User
 
Join Date: Oct 2005
Posts: 30
how to get primary key ?

i would like to get primary key by system tables, is there any way?

Find the table sysconstraints, and sysindexes, but still cant find link to syscolumns, in order to get columns which are primary key.
Reply With Quote
  #2 (permalink)  
Old 09-17-07, 09:56
gvee gvee is offline
www.gvee.co.uk
 
Join Date: Jan 2007
Location: UK
Posts: 10,156
sysobjects type 'K' ?
__________________
George
Twitter | Blog
Reply With Quote
  #3 (permalink)  
Old 09-17-07, 09:59
meiwen meiwen is offline
Registered User
 
Join Date: Oct 2005
Posts: 30
Quote:
Originally Posted by georgev
sysobjects type 'K' ?

Error: The specified table (sysobjects) is not in the database.


seems sysobjects doesnt exist in informix.
Reply With Quote
  #4 (permalink)  
Old 09-18-07, 04:12
meiwen meiwen is offline
Registered User
 
Join Date: Oct 2005
Posts: 30
after struggling, i got it :

select colname
from systables a, sysconstraints b, sysindexes c , syscolumns d
where a.tabname = 'cust_ppaid_v2'
and a.tabid = b.tabid
and a.tabid = c.tabid
and a.tabid = d.tabid
and b.constrtype ='P'
and b.idxname = c.idxname
and (
colno = part1 or
colno = part2 or
colno = part3 or
colno = part4 or
colno = part5 or
colno = part6 or
colno = part7 or
colno = part8 or
colno = part9 or
colno = part10 or
colno = part11 or
colno = part12 or
colno = part13 or
colno = part14 or
colno = part15 or
colno = part16
)
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On