Reputation: 13270
i try to check the syntax of an email when inserting a new value, but this doesn't seem to work :
create table foo (
email varchar(100) not null,
constraint foo_check1 check (email like '%@%.%')
);
insert into foo values ('bar'); /* OK ...why ? */
Upvotes: 0
Views: 88
Reputation: 611
This is a known limitation of MySQL - check constraints are not supported on CREATE TABLE
.
See: "The CHECK clause is parsed but ignored by all storage engines"
You should create your table first, then alter it to add the check constraints.
Upvotes: 1