表结构:
create table T_BUMP_CURVE
(
  BUMP_CURVE_ID NUMBER(10) not null,--主键
  HEAD          NUMBER(10,4),
  POWER         NUMBER(10,4),
  EFFICENCY     NUMBER(10,4),
  FLOW          NUMBER(10,4),
  DF            NUMBER(1) default 0 not null,
  BUMP_ID       NUMBER(10)
)我的insert语句insert into t_bump_curve
(select 1 as bump_id, head,power,efficency,flow,df
from t_bump_curve t
where t.df=0
and t.bump_id=23)这时主键该如何insert进去?

解决方案 »

  1.   


    insert into t_bump_curve 
    (
    select 1, head,power,efficency,flow,df 
    from t_bump_curve t 
    where t.df=0 
    and t.bump_id=23
      

  2.   

    将表里符合条件的记录再添加到原表里,重设id?
    主键应该用一个序列sequence
    这样的话就能使用seq.nextval填充主键
      

  3.   

    用cursor  再for   loop 即可写入主键
      

  4.   

    没有序列的话
    create sequence ..创建序列。具体你google一下,有很详细的介绍
    将序列的初始值设为你原表的最大值+1
    就可以用
    insert into t_bump_curve 
    (select seq.nextval, head,power,efficency,flow,df 
    from t_bump_curve t 
    where t.df=0 
    and t.bump_id=23) 
      

  5.   

    我select了seq.nextval提示序列不存在但是我看了下sequence文件夹下有t_bump_curve的,点进去之后
    -- Create sequence 
    create sequence S_BUMP_CURVE
    minvalue 1
    maxvalue 9223372036854775807
    start with 341
    increment by 1
    cache 10;
    确实是有的
      

  6.   

    有的话你就用s_bump_curve.nextval插入