1. 程式人生 > >oracle 觸發器 序列

oracle 觸發器 序列

使用序列生成ID
create sequence SEQ_SPBBL(序列名稱)
minvalue 1
maxvalue 9999999999999999999999999999
start with 1
increment by 1
cache 10;

create or replace trigger tri_SPBBL(觸發器名)
  before insert on f_SPBBL(表名)
  for each row
declare
  -- local variables here
begin
  IF :NEW.ID IS NULL THEN
  SELECT seq_SPBBL.NEXTVAL INTO :NEW.ID FROM DUAL;
  END IF;
end tri_SPBBL;