List:General Discussion« Previous MessageNext Message »
From:Martijn Tonies Date:November 28 2003 5:45pm
Subject:Re: CHECK constraint
View as plain text  
Hi,


> 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 ?

MySQL doesn't support CHECK constraints:
http://www.mysql.com/doc/en/CREATE_TABLE.html

With regards,

Martijn Tonies
Database Workbench - developer tool for InterBase, Firebird, MySQL & MS SQL
Server.
Upscene Productions
http://www.upscene.com

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