-- 当表SC的Grade属性进行修改是,若分数增加了10%,则将此次操作记录到另一个表SC_U(Sno,Cno,Oldgrade,Newgrade)中,其中Oldgrade是修改前的分数,Newgrade为修改后的分数 CREATETRIGGER SC_T AFTER UPDATE OF Grade ON SC REFERENCING OLDROW AS OldTuple. NEWROW AD NewTuple FOREACHROW WHEN(Newtuple.Grade>=1.1*OldTuple.Grade) INSERTINTO SC_U(Sno,Cno,OldGrade,NewGrade) VALUES(OldTuple.Sno,OldTuple.Cno,OldTuple.Grade,NewTuple.Grade); -- 将每次对表Student的插入操作所增加的学生个数记录到表Student-InsertLog中 CREATETRIGGER Student_Count AFTER INSERTON Student REFERENCING NEWTABLEAS DELTA FOREACH STATEMENT INSERTINTO StudentInsertLog(Numbers) SELECTCOUNT(*) FROM DELTA; -- 定义一个BEFORE行级触发器,为教师表Teacher定义完整性规则“教授的工资不得低于4000元,如果低于4000元,自动改为4000元” CREATETRIGGER Insert_Or_Update_Sal BEFORE INSERTOR UPDATE ON Teacher REFERENCINGNEWrow AD newTuple FOREACHROW BEGIN IF (newtuple.Job='教授')AND(newtuple.Sal<4000) THEN newTuple.Sal:=4000; END IF; END;