一种 特殊 的存储过程(https://blog.csdn.net/Leo_01169/article/details/85055744),
通过 增删改 的动作来触发执行,没有参数,没有返回值 满足条件时执行,否则不执行
触发器是一种与表操作有关的数据库对象,当触发器所在表上出现
指定事件时,将调用该对象,也就是说,对表的操作事件会触发表上的触发器的执行。
触发器的创建
DELIMITER $
create trigger tri_stuInsert after insert
on student for each row
begin
declare c int;
set c = (select stuCount from class where classID=new.classID);
update class set stuCount = c + 1 where classID = new.classID;
end$
DELIMITER ;
查看触发器
SHOW TRIGGERS [FROM schema_name];
删除触发器
DROP TRIGGER [IF EXISTS] [schema_name.]trigger_name