当前位置: 移动技术网 > IT编程>数据库>Oracle > Oracle 实现类似SQL Server中自增字段的一个办法

Oracle 实现类似SQL Server中自增字段的一个办法

2017年12月12日  | 移动技术网IT编程  | 我要评论

弃夫自逍遥,灵丘588,3月节日

相关代码如下:
1. 创建sequence:
复制代码 代码如下:

create sequence sequ_data_datainfo increment by 1 start with 1 nocycle nocache noorder;

2. 创建触发器:
复制代码 代码如下:

create or replace trigger trig_test
before insert on table1
for each row
declare
tmpvar number;
begin
tmpvar := 0;
select sequ_proc_associateinfo.nextval into tmpvar from dual;
:new.procid:=tmpvar;
exception
when others then
-- consider logging the error and then re-raise
raise;
end;

如对本文有疑问,请在下面进行留言讨论,广大热心网友会与你互动!! 点击进行留言回复

相关文章:

验证码:
移动技术网