分享一个mysql/chufaqi/ target=_blank class=infotextkey>mysql触发器的例子,代码如下:
create table test( percent decimal ); delimiter $$ CREATE TRIGGER test_before_insert BEFORE INSERT ON test FOR EACH ROW BEGIN IF NEW.percent < 0.0 OR NEW.percent > 1.0 THEN SET NEW.percent = NULL; END IF; END$$ delimiter ; drop trigger test_before_insert; drop table test;