does mysql not allow the keyword 'check' ?

Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.

Moderator: General Moderators

Post Reply
User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

does mysql not allow the keyword 'check' ?

Post by lazy_yogi »

does mysql not allow the keyword 'check' ?

eg .. this doesnt work

CREATE TABLE ex (
sess char(2) not null check (sess in ('S1','S2','X1','X2'))
);
User avatar
twigletmac
Her Royal Site Adminness
Posts: 5371
Joined: Tue Apr 23, 2002 2:21 am
Location: Essex, UK

Post by twigletmac »

It depends what table types you are using:
http://www.mysql.com/doc/en/CREATE_TABLE.html
MySQL Manual wrote:In MySQL Version 3.23.44 or later, InnoDB tables support checking of foreign key constraints. See section 7.5 InnoDB Tables. Note that the FOREIGN KEY syntax in InnoDB is more restricted than the syntax presented above. InnoDB does not allow index_name to be specified, and the columns of the referenced table always have to be explicitly named. Starting from 4.0.8 InnoDB supports both ON DELETE and ON UPDATE actions on foreign keys. See the InnoDB manual section for the precise syntax. See section 7.5 InnoDB Tables. For other table types, MySQL Server does parse the FOREIGN KEY, CHECK, and REFERENCES syntax in CREATE TABLE commands, but without further action being taken. See section 1.7.4.5 Foreign Keys.
Mac
User avatar
lazy_yogi
Forum Contributor
Posts: 243
Joined: Fri Jan 24, 2003 3:27 am

Post by lazy_yogi »

MySQL Server does parse the FOREIGN KEY, CHECK, and REFERENCES syntax in CREATE TABLE commands, but without further action being taken.
That's rediculous.
My current version of MySQL does not referential checks on foreitgn keys and doesnt even have syntax for CHECK kewords
Post Reply