我的Oracle中用Sequence和Triger给某一个表设置了主键自增,但是我现在要批处理运行SQL语句,希望插入数据到表中以后,主键值为插入语句中设置的值。
例如:当前有一个Student表,有student_id,name,设置自增因子为1
使用insert into Student(student_id,name) values(2,'tom') 。 如果不做任何其它的处理,运行后插入到表的数据为:1,tom。我想要在插入前怎么处理,让其插入后表中数据为:2,tom. 也就是表中插入的数据的主键为插入信息中的主键,而不是Oracle自增的值请大家帮忙啊!
例如:当前有一个Student表,有student_id,name,设置自增因子为1
使用insert into Student(student_id,name) values(2,'tom') 。 如果不做任何其它的处理,运行后插入到表的数据为:1,tom。我想要在插入前怎么处理,让其插入后表中数据为:2,tom. 也就是表中插入的数据的主键为插入信息中的主键,而不是Oracle自增的值请大家帮忙啊!
ALTER TRIGGER t2_tr1 ENABLE;