alter table 表名 add id int identity(1,1) 0 ;

解决方案 »

  1.   

    oracle中怎样将字段建成象SQL2000中的ID自动+1的字段
     两种方法
    方法一:
      用触发器建一个序列
       create sequence a_seq increment by 1 start with 100;
    建一个触发器, 自动+1
    create or replace trigger your_seq_tri
    before insert on your_table1 for each row
    declare
      next_id number;
    begin
      select your_seq.nextval into next_id from dual;
      :new.id := next_id;
    end;
    方法二:
      建一个序列
         create sequence a_seq increment by 1 start with 100;
       在语句中+1
      insert into tbl(id,....)
         values (a_seq.nextval,....)
      

  2.   

    create sequence seq_name 
    increment by 1
    start with 1
    maxvalue 999999999
    nocycle
    cache 10--使用:
        insert into table(id,name) values(seq_name.nextval,'9116 (天马) ')
      

  3.   

    MADE ,这个问题我问过了,可惜啊,好象也只有这个方法了,感觉就是每个表要对应一个SEQUENCE和触发器,能不能做一个通用行好一点的东西啊。
    大家一起构思一下吧
      

  4.   

    应该就只有使用触发器和序列的方法了。同意freddy2003()