By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
438,609 Members | 2,246 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 438,609 IT Pros & Developers. It's quick & easy.

When are CHECK constraints evakuated?

P: n/a
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
Share this Question
Share on Google+
1 Reply


P: n/a
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.