定義個結構體陣列
type ty_parmeter is record
(v_hezuotype number(1),
v_comefrom varchar2(50),
v_regchannel varchar2(50),
v_newchannel nvarchar2(30)
) ;type ty_parmeter_table is table of ty_parmeter index by binary_integer;
parameter_arry ty_parmeter_table;
begin
for i in 1..14
loop
update t_gather_userinfo
set f_reg_channel=parameter_arry(i).f_channel,
f_updatedate=sysdate
where f_type = parameter_arry(i).f_type
and f_come =parameter_arry(i).f_come
and f_reg =parameter_arry(i).f_reg
and f_reg_channel is null;
v_rownum :=sql%rowcount;
commit;
end loop;
for i in 15..22 loop
update t_gather_userinfo
set f_reg_channel=parameter_arry(i).f_channel,
f_updatedate=sysdate
where f_type = parameter_arry(i).f_type
and f_come like parameter_arry(i).f_come
and f_reg =parameter_arry(i).f_reg
and f_reg_channel is null;
v_rownum :=sql%rowcount;
commit;
end loop;
update t_gather_userinfo
set f_reg_channel=parameter_arry(23).f_channel,
f_updatedate=sysdate
where f_reg_channel is null;
v_rownum :=sql%rowcount;
commit;
這段** 在8個cpu 32核 30g記憶體機器上跑 時間 1分鐘,16分鐘 26,28,30分鐘
要遷到差勁2個cpu 8核的機器上 跑的後果是 分別為 114,116,115,146分鐘 update 1萬9千條資料
採用case when寫法 就全表掃瞄一次
mysql多條更新
最近在完成mysql專案整合的情況下,需要增加批量更新的功能,根據網上的資料整理了一下,很好用,都測試過,可以直接使用。mysql 批量更新共有以下四種辦法 1 replace into 批量更新 replace into test tbl id,dr values 1,2 2,3 x,y 例子 r...
關於CASE WHEN的多條件彙總問題
問題 建立測試表 if exists select from sys.objects where object id object id n dbo tb and type in n u drop table dbo tb1 gocreate table dbo tb1 卡狀態 nvarchar 2...
EntityFramework更新多條資料 8萬
此文主要用做記錄用 原因 資料庫遷移,需要轉換大量使用者資料,兩資料某欄位加密方式不一致需要批量轉換 注 轉換程式用了entityframework 過程 1.讀取所有需要轉換資料至list 2.採用parallel.foreach對list進行批次資料轉換 3.將轉換後的list資料按一定數量進行...