I have a problem with CONSTRAINTs
This is what I am using:
mysql> SHOW VARIABLES LIKE "%version%";
+-------------------------+------------------------------+
| Variable_name | Value |
+-------------------------+------------------------------+
| innodb_version | 1.1.8 |
| protocol_version | 10 |
| slave_type_conversions | |
| version | 5.5.16 |
| version_comment | MySQL Community Server (GPL) |
| version_compile_machine | x86 |
| version_compile_os | Win32 |
+-------------------------+------------------------------+
I tried to add a CHECK constraint for the gender. I tried both these and without success. I saw a lot of people report it as a bug, but not sure if it's a but or I do something wrong.
Code:
CHECK(gender IN ('M', 'F'));
CHECK (gender LIKE '[MF]');
I tried
Quote:
ALTER TABLE users
ADD CONSTRAINT CHECK (gender LIKE '[MF]')
|
as well as
Code:
CONSTRAINT ck_gender CHECK (gender in ( 'M', 'F' ) )
when define the table.
Is my syntax wrong? Thank you for your time.