declare trigger trigger_name trigger_event ON table_name FOR EACH ROW trigger_body
- trigger_name 触发器名称
- trigger_event 事件 before和after
如下创建一个插入test_trigger表之前插入另一个表test_trigger_log中一条数据
create trigger before_insert
before insert on test_trigger
for each row
insert into test_trigger_log
(t_log)
values
('before_insert');
查看触发器
- show triggers
- show create trigger
- information_schema
删除触发器
drop trigger [if exists] trigger_name