先建个squence,然后用触发器可以实现

解决方案 »

  1.   

    第一步:创建SEQUENCE
    create sequence s_country_id increment by 1 start with 1 maxvalue 999999999;
    第二步:创建一个基于该表的before insert 触发器,在触发器中使用该SEQUENCE
    create or replace trigger bef_ins_t_country_define
    before insert on t_country_define
    referencing old as old new as new for each row
    begin
    select s_country_id.nextval into :new.country_id from dual;
    end;
    /
      

  2.   

    create sequence xy minvalue 1202200204150001 maxvalue 1202200204159999 nocycle;
    drop sequence xy;
    select xy.nextval from dual;以后用select xy.currval from dual可得当前值,nextval 可取得并增加其值。
    最好自己也看点这种资料,很多的。