mysql触发器
1. 触发器的使用 create table customerHistory like customer; alter table customerHistory add updated DATETIME; desc customerHistory; 创建一个名为trg_customer_history的触发器,在删除customer表中的数据时触发 create trigger trg_customer_history after delete on customer for each row begin insert into customerHistory (mid,nam,birth,sex,updated) values(old.mid,old.nam,old.birth,old.sex,NOW()); end select * from customer; INSERT into customer values('A0001','小王','1990-1-2',0); delete from customer where customer.mid = 'A0001'; select * from customerHistory; 查询创建的触发器 show triggers; 可以使用的关键词与事件的关系 inster NEW update OLD 和 NEW