dbTalk Databases Forums  

How to check if FK is enforced or not

comp.databases.ibm-db2 comp.databases.ibm-db2


Discuss How to check if FK is enforced or not in the comp.databases.ibm-db2 forum.



Reply
 
Thread Tools Display Modes
  #1  
Old   
Damir
 
Posts: n/a

Default How to check if FK is enforced or not - 09-22-2010 , 12:11 PM






Hi,
is there a way (by executing a SQL statement) to find out which FKs defined
against a given table are enforced and which are not?
SYSCAT, SYSPROC, SYSIBMADM... something?
I cannot find it :-(
(DB2 V9.7.2 LUW)

Greetings,
Damir

Reply With Quote
  #2  
Old   
Lennart Jonsson
 
Posts: n/a

Default Re: How to check if FK is enforced or not - 09-22-2010 , 03:50 PM






On 2010-09-22 19:11, Damir wrote:
Quote:
Hi,
is there a way (by executing a SQL statement) to find out which FKs defined
against a given table are enforced and which are not?
SYSCAT, SYSPROC, SYSIBMADM... something?
I cannot find it :-(
(DB2 V9.7.2 LUW)
A trick is to make an educated guess on what the column might be named:

[lelle@c-83-219-209-129 ~]$ db2 "select tabschema, tabname from
syscat.columns where colname = 'ENFORCED'"

TABSCHEMA TABNAME
---------------------------
SYSCAT TABCONST
SYSIBM SYSTABCONST

2 record(s) selected.

You are probably looking for syscat.tabconst


One thing that strikes me as odd from time to time is that the remarks
column is null for the catalog table/columns. It would be nice to be
able to search for info via descriptions of columns/tables.


/Lennart

Reply With Quote
  #3  
Old   
Mark A
 
Posts: n/a

Default Re: How to check if FK is enforced or not - 09-23-2010 , 12:31 AM



"Damir" <damirwilder (AT) yahoo (DOT) com> wrote

Quote:
Hi,
is there a way (by executing a SQL statement) to find out which FKs
defined against a given table are enforced and which are not?
SYSCAT, SYSPROC, SYSIBMADM... something?
I cannot find it :-(
(DB2 V9.7.2 LUW)

Greetings,
Damir
You need to look in the DB2 System Catalog Views (which have a schema name
of SYSCAT). They are documented in the "SQL Reference Vol 1
Appendix D. System catalog views" manual.

I would look in the TABCONST view.

Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.3
Copyright ©2000 - 2012, Jelsoft Enterprises Ltd.