第一步:创建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;
/

解决方案 »

  1.   

    创建SEQUENCE
    create sequence s_country_id increment by 1 start with 1 maxvalue 999999999;
      

  2.   

    --建立序列
    create sequence seq_name
    increment by 1
    start with 1
    maxvalue 99999999
    nocycle
    cache 10--调用:
    insert into table(id,name) values(seq_name.nextval,'yourname');
      

  3.   

    序列名.nextval,只有这种方法了,如果不使用触发器
      

  4.   

    第一步:创建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;
    /
    来晚了