美文网首页
oracle 主键自增

oracle 主键自增

作者: 不懂i_ | 来源:发表于2017-09-30 11:11 被阅读0次

    第一步

    create table test
    (id int primary key,
    name varchar2(10));
    

    第二步 创建主键seq

    create sequence test_seq increment by 1 start with 1 
    minvalue 1 maxvalue 9999999999999 nocache 
    order;
    

    第三步 绑定触发

    create or replace trigger test_trigger
    before insert on test
    for each 
    row
    begin
     select  test_seq.Nextval into:new.id from dual;
    end;  

    相关文章

      网友评论

          本文标题:oracle 主键自增

          本文链接:https://www.haomeiwen.com/subject/bpaodxtx.html