oracle自增

前端之家收集整理的这篇文章主要介绍了oracle自增前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
create sequence S_USER;
/

create trigger tib_USER before insert on USER for each row declare integrity_error exception;
    errno            integer;
    errmsg           char(200);
    dummy            integer;
    found            boolean;

 begin -- Column id uses sequence S_USER select S_USER.NEXTVAL INTO :new.objectid from dual;

-- Errors handling
exception
    when integrity_error then
       raise_application_error(errno,errmsg);
end;
/

有几个地方注意,先创建序列create sequence S_USER。 再创建触发器,创建触发器的时候: select S_USER.NEXTVAL INTO :new.objectid from dual; new.objectid,objectid就是自增字段

原文链接:https://www.f2er.com/oracle/206345.html

猜你在找的Oracle相关文章