必须用触发器啊?没有像access和sql server 一样简单一点的自增方法啊?

解决方案 »

  1.   

    首先创建一个序列;
    create sequence seq_name 
    increment by 1
    start with 1
    no maxvalue
    no cycle
    cache 10;
    然后调用:
    insert into table(id,name....) values(seq_name.nextval,'miaohong2820'...)
      

  2.   

    create sequence时如何创建成000031或者A00031这种的sequence?
    1.  建序列:create sequence s1 start with 1 increment by 1
    2.  insert into t1(col) values('A' ||lpad(to_char(s1.nextval),10,'0'));
      

  3.   

    采用序列
    create sequence seq_name 
    increment by 1
    start with 1
    no maxvalue
    no cycle
    cache 10;
    调用:insert into table(id) values(seq_name.nextval)
      

  4.   

    采用序列和触发器
    /*创建序列*/
    create sequence Cj_dt_BWasteRecordSN
          INCREMENT BY 1
          START WITH 1
          MINVALUE 0
          MAXVALUE 999999999
          NOCYCLE
          NOORDER
          CACHE 20;/*创建触发器*/
    create or replace trigger insert_Cj_dt_BWasteRecordSN
    before insert on Cj_dt_BobbiningWasteRecord
    referencing old as old new as new 
    for each row 
    begin
        select Cj_dt_BWasteRecordSN.nextval into :new.SerialNum from dual;
    end;