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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Constarints

Status
Not open for further replies.

runa12345

IS-IT--Management
Jul 13, 2006
9
US
Hi All,
I am new to sql query. I want to select only constraints(keys) from the table. How can i do it in a query.

Thank you
 
Hi,

Not that simple a task since DB2 does not use 'keys' as you would see them defined. Probably your best bet is to use the SYSIBM.SYSKEYS table to look at the column names in the indexes for the table you are selecting for. Then link this back to the SYSCOLUMNS table and then back to your query table.

One gotcha though would be that you do not know that the index has only your key fields - or is an index for searching non-key fields. I am sure there is a way to determine that the index has a unique contraint which should then be the defintion of your keys.... just haven't found it yet.

Good luck.

 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top