Results 1 to 4 of 4
  1. #1
    Join Date
    Jan 2003
    Posts
    1,605

    Unanswered: 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

  2. #2
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    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.

  3. #3
    Join Date
    Jan 2003
    Posts
    1,605
    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

  4. #4
    Join Date
    Aug 2001
    Location
    UK
    Posts
    4,650
    You are right

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

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •