实现oracle主键自加

有一个表aline,主键为objectid

create sequence SEQ_Userinf start with 1 increment by 1
nomaxvalue
nominvalue
nocache;

CREATE OR REPLACE TRIGGER tg_test
BEFORE INSERT ON aline
FOR EACH ROW WHEN (new.objectid is null)
begin
select SEQ_Userinf.nextval into:new.objectid from dual;
end;

猜你喜欢

转载自blog.csdn.net/baidu_23263735/article/details/82949140