按不同條件更新資料

2021-08-30 23:25:01 字數 940 閱讀 7231

update cdsia set inen = $ where cuno=$ and inen is null;

update cdsia set s*** = $ where cuno=$ and s*** is null;

……update cdsia set bday = $ where cuno=$ and bday is null;

以上是待合併的語句:

一下為合併後語句:

update cdsia set cnno = case when (cnno is null or trim(cnno)='') then '$' else cnno end,

stdt = case when (stdt is null or trim(stdt)='') then '$' else stdt end,

eddt = case when (eddt is null or trim(eddt)='') then '$' else eddt end

where cuno = '$';

這樣可以將多條update語句合併為一條,以提高執行效率。

下面是效率比較:

寫道我的測試結果:

執行1000次,多句update:

real 0m41.90s

user 0m8.89s

sys 0m8.16s

單句update:

real 0m37.33s

user 0m8.26s

sys 0m7.47s

執行100次,多句update:

real 0m4.57s

user 0m0.89s

sys 0m0.81s

單句update:

real 0m3.69s

user 0m0.83s

sys 0m0.75s

ExtJS Grid 按條件載入資料

var startdate new date format y m d var enddate new date add date.day,7 format y m d var store new ext.data.store reader new ext.data.jsonreader liste...

按條件匯出excel資料

按條件匯出excel資料 寫法1 proc export data hbq.tmp double card 51 6 firstobs 1 obs 65486 outfile c users ex wljr huangbiquan downloads 二類戶促動測試群購買資料採集.xls repla...

不同條件剔除資料

1,張三,23 2,李四,24 3,王五,25 4,趙六,26 5,田七,25需求 剔除年齡為25 姓名為張三的資料 object culltest logger.getlogger org setlevel level.error val spark sparksession builder ma...