1.能够数据库做的就让数据库做
这里是对于稽核来说的,比如匹配数据代码里面里面要套循环浪费了很多次的无用循环,
能直接在数据库查出匹配数据就在数据库查询匹配数据,直接走更新路线就可以了
2.数据库必须要写索引特别where条件判断的部分对于插入效率、 查询判断影响很大的
Create Index I_LONG_SHORT_BILL_0 on LONG_SHORT_BILL(bill_type,searil_no);
3.对于大数据量的操作能用not exists 不要用not in
对于下面的这个语句差距很大的注意判断条件为空的情况
update bis_acc_his_dtl b
set b.jh_code = '', b.jh_state = '0'
where b.sk_type in ('002', '003', '004')
and b.issend = '0'
and b.jh_code is not null
and not exists
(select 1 from sqb_detail s where s.jh_code2 =b.jh_code);
4.oracle数据库里面insert带where条件的语句例子
insert into table(1,2,3) select * from daul where not exists();
INSERT INTO BDP_DETAIL
(ID,
TIME_STAMP,
SEARIL_NO,
ORDER_NO_REF,
STORE_CODE,
SALE_DATE,
SALE_COUNT,
YS_COLLECTION_MODE,
AMT,
TRANSINDEX,
PAYMENT_NO,
CARD_NO,
ROWKEY)
select
BDP_DETAIL_SEQ.NEXTVAL , '20190329011600.1821780', 'HD190329006835100811', '', 'A07K', to_date('20190329','yyyy-MM-dd'), '0', '2001', '83.0', '4', '', '', '3' from dual where not exists(select 1 from BDP_DETAIL s where s.searil_no='HD190329006835100811' and s.ys_collection_mode='2001' and s.amt='83.0')