您的当前位置:首页正文

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

2020-11-09 来源:意榕旅游网

创建序列: 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

显示全文