orcale设置自增列

mac2022-07-05  17

create sequence SEQ_ERRORID minvalue 1 maxvalue 99999999 start with 1000 increment by 1 nocache order;

create or replace trigger tri_ERRORINFO_ERRORID --触发器名称 before insert on REPORT_ERRORINFO_PDF --Test是表名 for each row declare nextid number; begin IF :new.ERRORID IS NULL or :new.ERRORID=0 THEN --id是列名 select SEQ_ERRORID.nextval --S_Test正是刚才创建的序列 into nextid from sys.dual; :new.ERRORID:=nextid; end if; end tri_ERRORINFO_ERRORID;

DROP TRIGGER tri_ERRORINFO_ERRORID

drop sequence SEQ_ERRORID

转载于:https://www.cnblogs.com/leakeyash/p/3701291.html

最新回复(0)