If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

 
Go Back  dBforums > Database Server Software > DB2 > What is purpose of ENFORCED word in ADD CONSTRAINT command?

Reply
 
LinkBack Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old 06-07-06, 05:14
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
What is purpose of ENFORCED word in ADD CONSTRAINT command?

Hi,

What is purpose of "ENFORCED" in ADD CONSTRAINT command? What is different if "ENFORCED" is not used?

Sample:
ALTER TABLE DB2ADMIN.TEST ADD CONSTRAINT CC1149671640818 CHECK (CO1 IN ('A','B','C')) ENFORCED ENABLE QUERY OPTIMIZATION ;

Thanks,
Grofaty
Reply With Quote
  #2 (permalink)  
Old 06-07-06, 06:29
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
You can define a constraint without enforcing it ...
ie ,
in the above example if you have used 'NOT ENFORCED' instead of ENFORCED, then you will be able to insert a record with a value of D in COL1.
NOT ENFORCED is used when you are sure that the data is correct but want to let the optimizer know about the constraint ... As an example, in a star schema, you can define a refrential contraint between fact and dimension without enforcing it ... This way, the optimizer will know the relationship between the two tables, but the database engine will not enfore the referential constraint

HTH

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
  #3 (permalink)  
Old 06-07-06, 06:59
grofaty grofaty is offline
Registered User
 
Join Date: Jan 2003
Posts: 1,570
Sathyaram_s,

Thanks a lot. What is default value if I omit the enfore clause just like this:
ALTER TABLE DB2ADMIN.TEST ADD CONSTRAINT CC1149671640818 CHECK (CO1 IN ('A','B','C'))

The above command is working and it looks like "enforced" is used as default. Is this correct?

Thanks,
Grofaty
Reply With Quote
  #4 (permalink)  
Old 06-07-06, 08:58
sathyaram_s sathyaram_s is offline
Super Moderator
 
Join Date: Aug 2001
Location: UK
Posts: 4,534
You are right

Sathyaram
__________________
Visit the new-look IDUG Website , register to gain access to the excellent content.
Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search
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

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On