mysql增删改触发器

update

DROP TRIGGER IF EXISTS `student_update`;
CREATE TRIGGER `student_update` AFTER UPDATE ON `ff_students`
 FOR EACH ROW BEGIN
INSERT INTO ff_triggers(type,item_id,createtime) VALUES('student',new.sid,unix_timestamp(now()));
END

insert

DROP TRIGGER IF EXISTS `student_insert`;
CREATE TRIGGER `student_insert` AFTER INSERT ON `ff_students`
 FOR EACH ROW BEGIN
INSERT INTO ff_triggers(type,item_id,createtime) VALUES('student',new.sid,unix_timestamp(now()));
END

delete

DROP TRIGGER IF EXISTS `student_delete`;
CREATE TRIGGER `student_delete` BEFORE DELETE ON `ff_students`
 FOR EACH ROW BEGIN
INSERT INTO ff_triggers(type,item_id,createtime) VALUES('student',old.sid,unix_timestamp(now()));
END

你可能感兴趣的:(mysql,mysql,sql,trigger)