How to find primary key?
Posted in 1999
Topics: General Discussion
hi, I want to find out whether a column in a table is a primary key by using system catalog in Imformix. However, I can find in sysconstraints that there are really a column is primary key, but I can not decide which column it is. syscoldepend doesn't has corresponding item for such constrid with tabid and colno. Then, given a table name and a column name, how can I decide whether it is a primary key or not? Thanks in advance.
Jing Liu wrote: > > hi, I want to find out whether a column in a table is a primary key by > using system catalog in Imformix. > However, I can find in sysconstraints that there are really a column is > primary key, but I can not decide which column it is. syscoldepend > doesn't has corresponding item for such constrid with tabid and colno. > Then, given a table name and a column name, how can I decide whether it > is a primary key or not? Sysconstraints names the unique index that is supporting the primary key. The column(s) of that index is/are the primary key. Art S. Kagel
Thanks for your reply. However, I still don't know how to do. The result I got from sysconstraints is something like: constrid 419 constrname u191_419 owner jingliu tabid 191 constrtype P idxname 191_419 How can I determine which column it is from the constrid or idxname? How can I get the colno so that I can get the colname in syscolumns? Thank you very much. Jing Art S. Kagel wrote: > > Sysconstraints names the unique index that is supporting the primary key. > The column(s) of that index is/are the primary key. > > Art S. Kagel