当前位置:Gxlcms > mysql > Oracle中使用序列和触发器实现单个字段值自增长

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

时间:2021-07-01 10:21:17 帮助过:29人阅读

创建序列: create sequence ccxx_ver_seq start with 1 increment by 1; 创建触发器: create or replace trigger ccxx_ver_tri

创建序列:

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;

linux

人气教程排行