INCREMENT BY 1 -- 每次加幾個 START WITH 1 -- 從1開始計數 NOMAXVALUE -- 不設定最大值 NOCYCLE -- 一直累加,不迴圈 NOCACHE -- 不建緩衝區create or replace trigger TRIGGER_TB_DataApproval before insert on TB_DataApproval for each row declare -- local variable here begin -- Column "ID" uses sequence di_test_id select SEQ_TB_DataApproval.nextval into :new.ID from dual; end TRIGGER_TB_DataApproval;
Oracle 新建自增序列號和觸發器:
CREATE SEQUENCE SEQ_TB_DataApproval
INCREMENT BY 1 -- 每次加幾個 START WITH 1 -- 從1開始計數 NOMAXVALUE -- 不設定最大值 NOCYCLE -- 一直累加,不迴圈 NOCACHE -- 不建緩衝區create or replace trigger TRIGGER_TB_DataApproval before insert on TB_DataApproval for each row declare -- local variable here begin -- Column "ID" uses sequence di_test_id select SEQ_TB_DataApproval.nextval into :new.ID from dual; end TRIGGER_TB_DataApproval;