oracle中使用序列和触发器实现单个字段值自增长

 

创建序列:

create sequence ccxx_ver_seq start with 1 increment by 1;

 

创建触发器:

create or replace trigger ccxx_ver_trig

before insert on ccxx

for each row begin 

select ccxx_ver_seq.nextval into :new.version from dual;

end;

 

ccxx为触发器应用的表名

version为需要进行值自增长的字段名称

 

测试:

insert into ccxx(ID,XM,SFZH,XS_SZMD_ID) values('aa','aa','aa','aa');

commit;

你可能感兴趣的:(oracle)