HiveBrain v1.2.0
Get Started
← Back to all entries
snippetMinor

How to see, if a foreign key is enforced?

Submitted by: @import:stackexchange-dba··
0
Viewed 0 times
foreignseeenforcedhowkey

Problem

How can I see in IBM DB2, if a foreign key is in enforced Status?
In the systemviews REF_CONSTRAINTS and REFERENTIAL_CONSTRAINTS I see them, but I cannot see, if they are in enforced Status. Is there another System view, where I can see that?

Solution

Not sure what version of db2 you are using, but if it's LUW you can use SYSCAT.TABCONST (see column ENFORCED):

select enforced 
from syscat.tabconst 
where tabschema = ?
  and tabname = ?
  and constname = ?


FWIW, it is better to use the syscat views (vs sysibm), since they are more stable between versions.

Code Snippets

select enforced 
from syscat.tabconst 
where tabschema = ?
  and tabname = ?
  and constname = ?

Context

StackExchange Database Administrators Q#135257, answer score: 2

Revisions (0)

No revisions yet.