Hi,
your enum canbe NULL and is not indexed. So you can insert values not in enum,
replaced by NULL.
a solution is to UNIQUE index the enum column, and insert a unique bad value in
it.
Any value not in enum can not then be inseted :
mysql> create table enum_test(id int, name enum('test1','test2')
Hi,
Use enum with a default type and let mysql do the check for you.
The problem with an enum is that if you insert a value that's not in
the enum, MySQL doesn't stop the insert, it leaves the column empty.
This doesn't enforce data integrity like I think Chris wanted.
mysql> desc enum_tes
Selon Michael Kruckenberg <[EMAIL PROTECTED]>:
> A trigger is a good place to check the value, and change it, bit I
> don't believe you can actually generate a MySQL error within the
> trigger that will prevent the data from being inserted. Currently
> (unless there's been an update to triggers th
ANTs don't permit
any person or program to insert data directly via the table.
Rhino
- Original Message -
From: "Partha Dutta" <[EMAIL PROTECTED]>
To: "'Michael Kruckenberg'" <[EMAIL PROTECTED]>; <[EMAIL PROTECTED]>
Cc:
Sent: Saturday, J
? www.mysql.com/certification
> -Original Message-
> From: Michael Kruckenberg [mailto:[EMAIL PROTECTED]
> Sent: Saturday, June 25, 2005 10:57 AM
> To: [EMAIL PROTECTED]
> Cc: mysql@lists.mysql.com
> Subject: Re: CHECK constraint
>
> A trigger is a good place to check t
A trigger is a good place to check the value, and change it, bit I
don't believe you can actually generate a MySQL error within the
trigger that will prevent the data from being inserted. Currently
(unless there's been an update to triggers that's not yet in the
docs), you can only change t
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);
> Que