天天看點

Oracle - Trigger

A: 資料插入之前更新

CREATE OR REPLACE TRIGGER TablesNameID     before insert ON TablesName for each row     begin      --業務邏輯     end TablesNameID;      

B:資料插入之後更新

CREATE OR REPLACE TRIGGER TablesNameID     after insert ON TablesName for each row     begin      --業務邏輯     end TablesNameID;      

C:資料更新之後更新 

CREATE OR REPLACE TRIGGER TableNamesAfterUpdate     after UPDATE ON TableNames FOR EACH ROW     begin      --業務邏輯     end;      

D:資料更新之前更新

CREATE OR REPLACE TRIGGER TableNamesBeforeUpdate

before UPDATE ON TableNames FOR EACH ROW

begin

--業務邏輯

end;

C:混合情況下的自動觸發

Oracle - Trigger
Oracle - Trigger
CREATE OR REPLACE TRIGGER TabelNameTrigger      before INSERT OR UPDATE ON TableName     FOR EACH ROW     DECLARE     --參數     BEGIN       --業務邏輯       if :new.texture = '銅絲' then         :new.texture := 'Cu';       end if;       if :new.texture = '金絲' then         :new.texture := 'Au';       end if;     END;      

View Code

 

  作者:Jeremy.Wu

  出處:https://www.cnblogs.com/jeremywucnblog/

  本文版權歸作者和部落格園共有,歡迎轉載,但未經作者同意必須保留此段聲明,且在文章頁面明顯位置給出原文連接配接,否則保留追究法律責任的權利。