我想往一个表里追加一个项目,追加后表里数据不变,
而且这个项目的缺省值是序列,怎么能实现?
请高手赐教!

解决方案 »

  1.   

    http://blog.csdn.net/java3344520/archive/2009/12/01/4907591.aspx
    参考...
      

  2.   

    首先得创建一个序列,如:
    create sequence seq_test
    start with 1
    increment by 1
    maxvalue 9999999999
    minvalue 1
    cycle
    nocache;然后你再创建一个表比如test_01,插入insert into test_01 values(seq_test.nextval),这样没执行一次就是按照自动的序列增长
      

  3.   

    1.alter table table_name add  newcol number --添加新的列,用来记录序列
    2.create sequence seq--创建序列
    start with 1
    increment by 1
    maxvalue 9999999999
    minvalue 1
    cycle
    nocache;
    3.--创建触发器
    create or replace trigger tri
    insert on table_name 
    for each row
    begin
     select seq.NEXTVAL into :new.newcol from dual;
    end;
    4.--取出原来表中所有数据,重新插入数据,便会得到你想要的结果