<s>
A	O
check	B-Language
constraint	I-Language
is	O
a	O
type	O
of	O
integrity	O
constraint	O
in	O
SQL	B-Language
which	O
specifies	O
a	O
requirement	O
that	O
must	O
be	O
met	O
by	O
each	O
row	B-Application
in	O
a	O
database	B-Application
table	I-Application
.	O
</s>
<s>
The	O
constraint	O
must	O
be	O
a	O
predicate	B-Algorithm
.	O
</s>
<s>
It	O
can	O
refer	O
to	O
a	O
single	O
column	O
,	O
or	O
multiple	O
columns	B-Application
of	O
the	O
table	B-Application
.	O
</s>
<s>
The	O
result	O
of	O
the	O
predicate	B-Algorithm
can	O
be	O
either	O
TRUE	O
,	O
FALSE	O
,	O
or	O
UNKNOWN	O
,	O
depending	O
on	O
the	O
presence	O
of	O
NULLs	B-Language
.	O
</s>
<s>
If	O
the	O
predicate	B-Algorithm
evaluates	O
to	O
UNKNOWN	O
,	O
then	O
the	O
constraint	O
is	O
not	O
violated	O
and	O
the	O
row	B-Application
can	O
be	O
inserted	O
or	O
updated	O
in	O
the	O
table	B-Application
.	O
</s>
<s>
This	O
is	O
contrary	O
to	O
predicates	B-Algorithm
in	O
WHERE	B-Language
clauses	O
in	O
SELECT	B-Language
or	O
UPDATE	B-Language
statements	O
.	O
</s>
<s>
For	O
example	O
,	O
in	O
a	O
table	B-Application
containing	O
products	O
,	O
one	O
could	O
add	O
a	O
check	B-Language
constraint	I-Language
such	O
that	O
the	O
price	O
of	O
a	O
product	O
and	O
quantity	O
of	O
a	O
product	O
is	O
a	O
non-negative	O
value	O
:	O
</s>
<s>
Check	B-Language
constraints	I-Language
are	O
used	O
to	O
ensure	O
the	O
validity	O
of	O
data	O
in	O
a	O
database	O
and	O
to	O
provide	O
data	O
integrity	O
.	O
</s>
<s>
Each	O
check	B-Language
constraint	I-Language
has	O
to	O
be	O
defined	O
in	O
the	O
CREATE	O
TABLE	B-Application
or	O
ALTER	O
TABLE	B-Application
statement	O
using	O
the	O
syntax	O
:	O
</s>
<s>
CONSTRAINT	O
constraint_name	O
CHECK	O
(	O
predicate	B-Algorithm
)	O
,	O
</s>
<s>
If	O
the	O
check	B-Language
constraint	I-Language
refers	O
to	O
a	O
single	O
column	O
only	O
,	O
it	O
is	O
possible	O
to	O
specify	O
the	O
constraint	O
as	O
part	O
of	O
the	O
column	O
definition	O
.	O
</s>
<s>
column_name	O
type	O
CHECK	O
(	O
predicate	B-Algorithm
)	O
,	O
</s>
<s>
A	O
NOT	O
NULL	B-Language
constraint	O
is	O
functionally	O
equivalent	O
to	O
the	O
following	O
check	B-Language
constraint	I-Language
with	O
an	O
IS	O
NOT	O
NULL	B-Language
predicate	B-Algorithm
:	O
</s>
<s>
Some	O
relational	B-Application
database	I-Application
management	I-Application
systems	I-Application
are	O
able	O
to	O
optimize	O
performance	O
when	O
the	O
NOT	O
NULL	B-Language
constraint	O
syntax	O
is	O
used	O
as	O
opposed	O
to	O
the	O
CHECK	B-Language
constraint	I-Language
syntax	O
given	O
above	O
.	O
</s>
<s>
Most	O
database	O
management	O
systems	O
restrict	O
check	B-Language
constraints	I-Language
to	O
a	O
single	O
row	B-Application
,	O
with	O
access	O
to	O
constants	O
and	O
deterministic	O
functions	O
,	O
but	O
not	O
to	O
data	O
in	O
other	O
tables	O
,	O
or	O
to	O
data	O
invisible	O
to	O
the	O
current	O
transaction	O
because	O
of	O
transaction	B-General_Concept
isolation	I-General_Concept
.	O
</s>
<s>
Such	O
constraints	O
are	O
not	O
truly	O
table	B-Application
check	B-Language
constraints	I-Language
but	O
rather	O
row	B-Application
check	B-Language
constraints	I-Language
.	O
</s>
<s>
Because	O
these	O
constraints	O
are	O
generally	O
only	O
verified	O
when	O
a	O
row	B-Application
is	O
directly	O
updated	O
(	O
for	O
performance	O
reasons	O
,	O
)	O
and	O
often	O
implemented	O
as	O
implied	O
INSERT	O
or	O
UPDATE	B-Language
triggers	B-Language
,	O
integrity	O
constraints	O
could	O
be	O
violated	O
by	O
indirect	O
action	O
were	O
it	O
not	O
for	O
these	O
limitations	O
.	O
</s>
<s>
Furthermore	O
,	O
otherwise-valid	O
modifications	O
to	O
these	O
records	O
would	O
then	O
be	O
prevented	O
by	O
the	O
CHECK	B-Language
constraint	I-Language
.	O
</s>
<s>
User-defined	O
triggers	B-Language
can	O
be	O
used	O
to	O
work	O
around	O
these	O
restrictions	O
.	O
</s>
<s>
Although	O
similar	O
in	O
implementation	O
,	O
it	O
is	O
semantically	O
clear	O
that	O
triggers	B-Language
will	O
only	O
be	O
fired	O
when	O
the	O
table	B-Application
is	O
directly	O
modified	O
,	O
and	O
that	O
it	O
is	O
the	O
designer	O
's	O
responsibility	O
to	O
handle	O
indirect	O
,	O
important	O
changes	O
in	O
other	O
tables	O
;	O
constraints	O
on	O
the	O
other	O
hand	O
are	O
intended	O
to	O
be	O
"	O
true	O
at	O
all	O
times	O
"	O
regardless	O
of	O
the	O
user	O
's	O
actions	O
or	O
the	O
designer	O
's	O
lack	O
of	O
foresight	O
.	O
</s>
