表结构:
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进去?
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进去?
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
)
主键应该用一个序列sequence
这样的话就能使用seq.nextval填充主键
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)
-- Create sequence
create sequence S_BUMP_CURVE
minvalue 1
maxvalue 9223372036854775807
start with 341
increment by 1
cache 10;
确实是有的