0

新しい値を挿入するときに電子メールの構文をチェックしようとしましたが、うまくいかないようです:

create table foo (
    email varchar(100) not null,
    constraint foo_check1 check (email like '%@%.%')
);

insert into foo values ('bar'); /* OK ...why ? */
4

1 に答える 1

1

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.

于 2012-07-19T07:34:01.287 に答える