Re: Problem with primary key
Posted in 1998
Vinhson,
Try the following query
select t.tabname, i1.colname, i2.colname
from syscolumns c,
systables t,
sysconstraints con,
sysindexes i1,
outer sysindexes i2
where con.constrtype = 'P' --- primary key only
and con.tabid = t.tabid
and con.tabid = c.tabid
and con.idxname = i1.idxname
and con.idxname = i2.idxname
and i1.part1 = c.colno
and i2.part1 = c.colno
You will need to have the outer to sysindexes if you have multipart
primary keys. If you do there is a maximum of 16 parts(columns) in
sysindexes that you will have to form outers to.
Regards
David Ashby
______________________________ Reply Separator _________________________________
Subject: Problem with primary key
Author: <nguyenv@cognos.com (Vinhson)> at WCA-INET
Date: 20/1/98 3:51 PM
Hello all,
I'm using Informix Server 7.2x. The Informix system table
sysconstraints allows me to find out if a given table, say
known_table, has a primary key via, for instance,
select * from informix.sysconstraints
where tabid = tabid_of_known_table
Suppose that the above select query indicated that known_table
has a primary key. Does anyone know how I can find the column name
associated with that key?
Any help or suggestion is very much appreciated.
Vinhson
Email: nguyenv@cognos.com