demo
添加
DROP TRIGGER IF EXISTS t_tab;
CREATE TRIGGER t_tab
AFTER INSERT ON friend
FOR EACH ROW
BEGIN
INSERT INTO friend_1(id,mqq,fqq,update1) VALUES(new.id,new.mqq,new.fqq,"add");
END;
insert into friend(mqq,fqq)VALUES(1,2);
修改
DROP TRIGGER IF EXISTS t_tab_update;
CREATE TRIGGER t_tab_update
AFTER UPDATE ON friend
FOR EACH ROW
BEGIN
UPDATE friend_1 set mqq=new.mqq,fqq=new.fqq,update1="up" where id=new.id;
END;
update friend set mqq=4 where id=79;
删除
DROP TRIGGER IF EXISTS t_tab_delete;
CREATE TRIGGER t_tab_delete
BEFORE DELETE ON friend
FOR EACH ROW
BEGIN
update friend_1 set update1="delete" where id=old.id;
END;
delete from friend where id=79;