oracle 添加自增索引

1.添加一个Sequence,此处为ID_SEQUENCE。

2.添加对应表,并设置主键

3.设置触发器

create or replace trigger sys.id_add
before insert on SWACK.NUSER
for each row
-- WHEN (new.id is null)
-- local variables here
begin
select SWACK.ID_SEQUENCE.NEXTVAL into :new.id from dual;
end id_add;

原文地址:https://www.cnblogs.com/swack/p/4362452.html