语句触发器
create trigger tr_book_add
after insert;
on t_book;
begin
if user!='scott' then
raise_application_error(-20001,'权限不足');
end if;
end;
触发器谓词:inserting、updating、deleting
if inserting then
else if updating then
else if deleting then
行触发器
内置变量:old、new
删除:old有值 修改:old、new有值 插入:new有值
create trigger tr_book_add
after insert;
on t_book;
for each row;
begin
update t_booktype set num:=num+1 where id=:new.typeId;
end;
create trigger tr_book_delete
after delete;
on t_book;
for each row;
begin
update t_booktype set num:=num-1 where id=:old.typeId;
end;
触发器禁用和开启
alter trigger 触发器名 disable //禁用
alter trigger 触发器名 enable //开启