Link to home
Start Free TrialLog in
Avatar of thomaszhwang
thomaszhwangFlag for United States of America

asked on

How to find out Primary Key information in the system tables?

In Informix, is there a way to find out the Primary Key information in the system tables?  Thanks.
SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
- to add further, you can use the following query, it will return the tablename for that Primarykey as the SYSCONSTRAINTS only contain the tableid :

SELECT a.tabname, constrname, d.tabname
  FROM systables a, sysconstraints b, sysreferences c,
       systables d
 WHERE b.constrtype = 'R'
   AND a.tabid = b.tabid
   AND b.constrid = c.constrid
   AND c.ptabid = d.tabid

http://publib.boulder.ibm.com/infocenter/idshelp/v10/index.jsp?topic=/com.ibm.sqlr.doc/sqlrmst47.htm
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
OP_Zaharin: thanks! It appears that because of the frames on IBM's site, my version of the link went to SYSCOLUMNS and not SYSCONSTRAINTS, so you provide both a wonderful code sample and the correct link. :)
Avatar of thomaszhwang

ASKER

Thank you guys.