identity是sybase中的一个概念,如果你想使这个字段唯一,你可以使用主键及sequence(序列)。

解决方案 »

  1.   

    oracle 中没有identity
    你得用序列
      

  2.   

    使用sequence
    create sequence sqname start with 1 increment by 1 maxvalue 100 nocycle
    insert into table values(sqname.nextval);Keyword Description
    START WITH Defines the first number that the sequence will
    generate. The default is one.INCREMENT BY Defines the increase or decrease for subsequently
    generated numbers. To specify a decreasing
    sequence, use a negative INCREMENT BY.MINVALUE The lowest number the sequence will generate.
    This is the bounding value in a decreasing
    sequence. The default MINVALUE is the keyword
    NOMINVALUE, which translates to 1 for an
    increasing sequence and to –1026 for a decreasing
    sequence.MAXVALUE The largest number that the sequence will
    generate. This is the bounding value in the
    default, increasing sequence. The default
    MAXVALUE is the keyword NOMAXVALUE which
    translates to 1027 for an increasing sequence and
    to –1 for a decreasing sequence.CYCLE Configures the sequence to repeat numbers after
    reaching the bounding value.NOCYCLE Configures the sequence to not repeat numbers
    after reaching the bounding value. This is the
    default. When you try to generate the
    MAXVALUE+1, an exception will be raised.CACHE Defines the size of the block of sequence
    numbers held in memory. The default is 20.NOCACHE Forces the data dictionary to be updated for each
    sequence number generated, guaranteeing no
    gaps in the generated numbers.
      

  3.   

    必须用Sequence和Tigger联合。
    第一步:创建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;