-- 插入数据触发器 create trigger student_insert_trigger after insert on student for each row begin -- 新row和旧row的数据可以通过new和old获取 insert into user_logs values (null, 'insert', now(), new.id, concat('插入的数据id=', new.id, ' name=', new.name, ' class=', new.class, ' degree=', new.degree)); end; -- 更新数据触发器 create trigger student_update_trigger after update on student for each row begin insert into user_logs values (null, 'update', now(), new.id, concat('更新之后的id=', new.id, ' name=', new.name, ' class=', new.class, ' degree=', new.degree, ' | 更新之前的id=', old.id, ' name=', old.name, ' class=', old.class, ' degree=', old.degree)); end; -- 删除数据触发器 create trigger student_delete_trigger after delete on student for each row begin insert into user_logs values (null, 'delete', now(), OLD.id, concat('删除之前的id=', old.id, ' name=', old.name, ' class=', old.class, ' degree=', old.degree)); end;
标签:触发器,old,name,degree,class,new,id From: https://www.cnblogs.com/WTSRUVF/p/17519386.html