我想用一个临时表存放另外几个表中的二个字段,而且为临时表设一个ID,当我向这个临时表存一条记录时,临时表的ID自动加1,有人知道怎么做吗?

解决方案 »

  1.   

    用sequence啊create sequence sequence_modify_record 
    minvalue 1
    maxvalue 99999999999999999999
    start with 1
    increment by 1
    cache 20

    使用:
    select sequence_modify_record.nextval into v_num from dual;
      

  2.   

    insert into temptab(col1,col2,col3) select a.col1,b.col2,c.col3 from table1 a,table2 b,table3 c where a.id=b.id and b.id=c.id;  这个上面不是三列吗,如果我增加一个自动增加的序列号,
    insert into temptab(sequence_modify_record.nextval,col1,col2,col3) select a.col1,b.col2,c.col3 from table1 a,table2 b,table3 c where a.id=b.id and b.id=c.id;
    是不是可以这样写,就是我在临时表中建了四个字段,三个字段是从别的表里查询出来的,另外一个是我自动增加的序列号?