-
數(shù)據(jù)庫出發(fā)器的基本概念 每當(dāng)一個(gè)特定的數(shù)據(jù)操作語句(insert,update,delete) 在制定的表上發(fā)出 (前一步或者后一步)時(shí),Oracle自動的執(zhí)行觸發(fā)器中定義的語句序列。?
第一個(gè)觸發(fā)器:每當(dāng)成功插入新員工后,自動打印"成功插入新員工" 觸發(fā)器(trigger)?
如何創(chuàng)建觸發(fā)器?
create trigger saynewmp?
after
?insert on emp?
declare
?begin?
?dbms_output.put_line('成功插入新員工') ;?
end;
?/
查看全部 -
觸發(fā)器是特殊的存儲過程
觸發(fā)器的應(yīng)用場景:?
復(fù)雜的安全性檢查
數(shù)據(jù)確認(rèn)
數(shù)據(jù)審計(jì)功能
完成數(shù)據(jù)的備份和同步
查看全部 -
觸發(fā)器的應(yīng)用場景: 1.復(fù)雜的安全性檢查 2.數(shù)據(jù)確認(rèn) 3.數(shù)據(jù)審計(jì)功能 4.完成數(shù)據(jù)的備份和同步
查看全部 -
行級觸發(fā)器之前和之后的值。
查看全部 -
觸發(fā)器的創(chuàng)建語法
查看全部 -
觸發(fā)器的應(yīng)用場景: 1.復(fù)雜的安全性檢查 2.數(shù)據(jù)確認(rèn) 3.數(shù)據(jù)審計(jì)功能 4.完成數(shù)據(jù)的備份和同步
查看全部 -
create trigger users after insert on user declare begin out(插入新員工) end /查看全部
-
觸發(fā)器是在執(zhí)行插入,更新,刪除語句時(shí),會自動調(diào)用。 create trigger 創(chuàng)建觸發(fā)器查看全部
-
函數(shù):raise_application_error(error_code,error_messege);
error_code要小于-20000
查看全部 -
觸發(fā)器應(yīng)用場景:
復(fù)雜的安全性檢查
數(shù)據(jù)確認(rèn)
實(shí)現(xiàn)審計(jì)功能
完成數(shù)據(jù)的備份與同步
觸發(fā)器的類型:
語句級觸發(fā)器
行級觸發(fā)器
查看全部 -
create or replace trigger sync_salary after update on emp for each row begin - -當(dāng)主表更新后,自動更新備份表 update emp_back set sal=:new.sal where empno=:new.empno; end;查看全部
-
create or replace trigger do_audit_emp_salary after update on emp for each row begin - - 當(dāng)漲后的薪水大于6000,插入審計(jì)信息 if :new.sal > 6000 then insert into audit_info values(:new.empno||' '||:new.ename||' '||:new.sal); end if; end;查看全部
-
create or replace trigger checksalary before update on emp for each row begin - - if漲后的薪水 < 漲前的薪水 then if :new.sal < :old.sal then raise_appliacation_error(-20002,'漲后的薪水不能少于漲前的薪水。漲前的薪水:'||:new.sal||'漲前的薪水:'||:old.sal); end if; end;查看全部
-
create or replace trigger securityemp before insert on emp begin if to_char(sysdate,'day')in('星期六','星期日') or to_number(to_char(sysdate,'hh24'))not between 9 and 18 then - - 禁止insert新員工 raise_application_error(-20001,'禁止在非工作時(shí)間插入新員工'); end if; end查看全部
-
create or replace trigger raisesal before update on emp for each row begin if '漲錢的工資'<“張厚的工資” raise_application_error(-20001,"錯(cuò)誤"); end if; end;查看全部
舉報(bào)