1. trigger 是自动提交的,不用COMMIT,ROLLBACK
2. trigger最大为32K,如果有复杂的应用可以通过在TRIGGER里调用PROCEDURE或FUNCTION来实现。
3. 语法
CREATE OR REPLACE TRIGGER <trigger_name>
<BEFORE | AFTER> <ACTION>
ON <table_name>
DECLARE
<variable definitions>
BEGIN
<trigger_code>
EXCEPTION
<exception clauses>
END <trigger_name>;
/
例子,trigger调用sequence自动添加主键id:
create sequence pk_sys_dictionary
start with 1
increment by 1
nocache;
create or replace trigger tri_sys_dictionary
before insert on sys_dictionary
for each row
declare
begin
select pk_sys_dictionary.nextval into :new.id from dual;
end;
/