create sequence SEQ_ID
minvalue 1
maxvalue 99999999
start with 1
increment by 1
nocache
order;
建解发器代码为:
create or replace trigger tri_test_id
before insert on person
for each row
declare
nextid number;
begin
IF :new.PERSON_IDZI IS NULL THEN
select SEQ_ID.nextval --SEQ_ID正是刚才创建的
into nextid
from sys.dual;
:new.PERSON_IDZI :=nextid;
end if;
end tri_test_id;
OK,上面的代码就可以实现自增长oracle标识列的功能了。