一:触发器响应的事件
数据库操作(DML)语句(DELETE,INSERT,UPDATE)
数据库定义(DDL)语句(CREATE,ALTER或DROP)
数据库操作(SERVERERROR,登录,注销,启动或关机)
二:创建触发器
CREATE [OR REPLACE ] TRIGGER trigger_name
{BEFORE | AFTER | INSTEAD OF }
{INSERT [OR] | UPDATE [OR] | DELETE}
[OF col_name]
ON table_name
[REFERENCING OLD AS o NEW AS n] //引用储存旧值的OLD表 和 新值的 NEW表
[FOR EACH ROW] //行级触发器,即触发器将每一行受到影响执行。否则,当执行SQL语句,这被称为表级触发器,触发将执行一次
WHEN (condition)
DECLARE
Declaration-statements
BEGIN
Executable-statements
EXCEPTION
Exception-handling-statements
END;