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

posted @ 2014-04-30 14:36  AshLeakey  阅读(241)  评论(0编辑  收藏  举报