CHECK constraint in MySQL is not working -


first created table like

create table customer (   sd integer check (sd > 0),   last_name varchar (30),   first_name varchar(30) ); 

and inserted values in table

insert customer values ('-2','abc','zz'); 

mysql doesn't show error, accepted values.

the mysql reference manual says:

the check clause parsed ignored storage engines.

try trigger...

mysql> delimiter // mysql> create trigger trig_sd_check before insert on customer      -> each row      -> begin      -> if new.sd<0      -> set new.sd=0;      -> end if;      -> end     -> // mysql> delimiter ; 

hope helps.


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -