vdegenne
vdegenne

Reputation: 13270

check for email domain in mysql doesn't work

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

Answers (1)

u25891
u25891

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

Related Questions