由merge into引起的序列跳号
最近生产库反应出一个问题,某张表的主键ID并没有按照原计划的期望增加,而是间歇性跳号,每次跳2万多,经过研究发现是某个同步过程的merge into引起的,具体语句如下
merge into t_ifi_invest_ordplan_detail a
using (select f.client_id,
f.fund_account,
f.fund_code,
f.fund_company,
f.balance,
f.allotno,
f.en_fund_date,
f.start_date,
f.end_date,
s.cpid,
s.cpmc
from t_ifi_ofrationtime f
left join t_ifi_singlefund_info s
on f.fund_code = s.cpdm
where f.deal_flag = '0' --过滤当日取消操作
) t on (a.allotno = t.allotno)
when not matched then
insert
(a.plan_detail_id,
a.plan_id,
a.client_id,
a.fund_account,
a.fund_code,
a.fund_company,
a.fix_invest,
a.allotno,
a.fund_id,
a.plan_name,
a.openacc_flag)
values
(seq_ifi_invest_ordplan_detail.nextval,
seq_ifi_invest_ordplan.nextval,
t.client_id,
t.fund_account,
t.fund_code,
t.fund_company,
t.balance,
t.allotno,
t.cpid,
t.cpmc || '普通定投' || seq_ifi_invest_ordplan.currval,
'1')
经过实验发现,虽然每次同步新增的数据不多,但是序列总是跳一个波段,而跳的间隔数刚好是本次using里面查到的数据总量,很是奇怪。
解决方法:单独写个获取序列的方法,将merge into 里面的seq_ifi_invest_ordplan_detail.nextval换成用方法获取序列,再次测试,问题解决。究竟原因目前还不得知,有知道的可以留言告知下,谢谢。
最新文章
- APP里如何添加本地文本
- JS控制div跳转到指定的位置的解决方案总结
- List 用法和实例(转载)
- yii2.0邮箱发送
- [MCSM] Slice Sampler
- 函数fseek() 用法(转)
- poj-1469-COURSES-二分图匹配-匈牙利算法(模板)
- 【转】Java中 List的遍历
- LNMP环境出现”504 gateway time-out”错误的解决方案
- 【排序】表插入排序算法(C语言版)
- 事务不提交,也有可能写redo和数据文件
- Python之列表&;元组&;字典
- Nodejs的多线程
- Linux下部署开源版“禅道”项目管理系统
- tp引入header文件~
- mysql 性能优化思路 - mysqldumpslow /tmp/mysql-slow.log 字符集 utf-8 create database
- linux硬盘挂载-新硬盘挂载和扩容硬盘挂载
- 【Codeforces 1110D】Jongmah
- Project Euler Problem6
- JDK自带的运行监控工具JConsole观察分析Java程序的运行