mysql触发器

1.创建触发器

create trigger trigger_name trigger_time  trigger_event on table_name for each row

begin

trigger_stmt

end

  • trigger_time:before或者是after
  • trigger_event:insert、update和delete
use oa;

--create table trigg select * from students where 1=2;
delimiter //
create trigger cus_trigger before insert on students for each row
begin
insert into trigg values(new.id,new.tname);
end //
delimiter ;

insert into students (tname)values('hehe');

  

2.删除触发器

drop trigger trigger_name;

posted @ 2018-01-23 09:41  orna  阅读(160)  评论(0编辑  收藏  举报