创建序列:create sequence SEQ
minvalue 1
maxvalue 999999999999999999999999999
start with 61
increment by 1
cache 30
order;使用:insert into tname values(SEQ.nextval,其他字段值)

解决方案 »

  1.   

    只能用语句来创建吗?不能在ORACLE 具体的一个表中设置吗?对了,insert into tname values(SEQ.nextval,其他字段值)这条语句中的其他字段值指的是什么?
    谢谢
      

  2.   

    可以使用 序列 和 触发器 相结合,来达到SQL 自增列的效果。
    建表
    create table foo( 
      id number primary key, 
      data varchar2(100)); ”
    建序列
    create sequence foo_seq; 
    建触发器
    create or replace trigger bifer_foo_id_pk 
       before insert 
        on foo 
         for each row 
    begin 
       select foo_seq.nextval into :new.id from dual; 
    end;