Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Primary Keys

Status
Not open for further replies.

gmoorthy

Programmer
Jul 13, 2004
107
US
I am using Informix Version 7.30.Is there a system table where i can do a query and get a list of Primary Keys on the userdefined tables on all the tables that has been built in the database.
 
Hi,

Run dbaccess & select your database and run the below query, change the values for column - owner

select * from sysconstraints
where owner = "jack"
and constrtype = "P
 
Hi,

The SQL below lists all the tables with primary & foreign key relationships.

select ptabid TABID,
substr((select tabname from systables where tabid=ptabid),1,18) PRIMARY,
tabname[1,18] FOREIGN,
constrname[1,18] IDXNAME,
decode(delrule,'C','Yes','No') CASCADE
from
sysconstraints c, sysreferences r, systables s
where
c.constrtype='R' and c.constrid=r.constrid and c.tabid=s.tabid and
ptabid in
(select tabid from sysconstraints where constrtype in ('P','U'))
order by 1;

Regards,
Shriyan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top