469,310 Members | 2,445 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,310 developers. It's quick & easy.

When are CHECK constraints evakuated?

When the "new" data IS NOT NULL or whenever the row is stored? In
particular is the first clause needed in:

ALTER TABLE IS3.FLUSHES
ADD CONSTRAINT PALP_LEFT_OV
CHECK (PALP_LEFT_OV IS NULL OR PALP_DATE IS NOT NULL)

Or would it suffice to say:

ALTER TABLE IS3.FLUSHES
ADD CONSTRAINT PALP_LEFT_OV
CHECK (PALP_DATE IS NOT NULL)
Nov 12 '05 #1
1 1268
Bob Stearns wrote:
When the "new" data IS NOT NULL or whenever the row is stored? In
particular is the first clause needed in:

ALTER TABLE IS3.FLUSHES
ADD CONSTRAINT PALP_LEFT_OV
CHECK (PALP_LEFT_OV IS NULL OR PALP_DATE IS NOT NULL)

Or would it suffice to say:

ALTER TABLE IS3.FLUSHES
ADD CONSTRAINT PALP_LEFT_OV
CHECK (PALP_DATE IS NOT NULL)


Both constraints have different semantics. The first ensures that the value
in column PALP_LEFT_OV is null and if it is not null, then PALP_DATE must
not be null either. The second constraint just says that PALP_DATE must
not be null, regardless of the value of PALP_LEFT_OV. So depending on what
you want to achieve, you might or might not need the first predicate.

A table constraint (actually that's just a row constraint) is checked for
the complete row. So if you change a single value only, DB2 will still
take the other values into consideration to determine if the constraint is
violated or not.

--
Knut Stolze
DB2 Information Integration Development
IBM Germany
Nov 12 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

1 post views Thread by huyuhui | last post: by
1 post views Thread by Dan Holmes | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by harlem98 | last post: by
1 post views Thread by Geralt96 | last post: by
reply views Thread by harlem98 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.