List:General Discussion« Previous MessageNext Message »
From: Date:January 1 1970 12:00am
Subject:CHECK constraint
View as plain text  
I created a table as follows:

mysql> CREATE TABLE test (
    -> age INT(3),
    -> CONSTRAINT CHECK (age > 0)
    -> );
Query OK, 0 rows affected (0.00 sec)

I then inserted -1 into the table, which it shouldn't
have let me do.

mysql> insert into test values (-1);
Query OK, 1 row affected (0.00 sec)

mysql> select *From test;
+------+
| age  |
+------+
|   -1 |
+------+
1 row in set (0.01 sec)

How can I enforce the CHECK constraint ?

thanks


Thread
CHECK constraintUnknown Sender28 Nov
  • Re: CHECK constraintMartijn Tonies28 Nov