orcale设置自增列

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

上一篇:BHP Net Tool


下一篇:gdb 调试程序