|
我都这样干:
假定从 1 开始,我会先写入一个从 0 开始的记录,防并且的效果还是不错的,你可以参考一下:
-- 这是表结构
create table t(id int, num int);
-- 写入 0 的记录
insert into t select 100, 0 from dual where not exists(select * from t where id = 100)
-- 生成序列( 1、2、3、4、5) 的记录
update t set num = num + 1 where id = 100 returning num into v_num;
欢迎大家指点!
如果 merge 有 returning ,就爽了。
|
|