實時測試的速度:
--48466條資料
--1.297
inline view更新法
inline view更新法就是更新乙個臨時建立的檢視
update (select a.join_stateas join_state_a,b.join_stateas join_state_b
from t_join_situation a, t_people_info b where a.people_number=b.people_number
and a.year='2011' and a.city_number='m00000' and a.town_number='m51000'
) set join_state_a=join_state_b
括號裡通過關聯兩表建立乙個檢視,set中設定好更新的字段。這個解決方法比寫法較直觀且執行速度快。但表b的主鍵一定要在where條件中,並且是以「=」來關聯被更新表,否則報錯誤
--7.156
update t_join_situation aset a.join_state=(select b.join_statefrom t_people_info b
where a.people_number=b.people_number
and a.year='2011' and a.city_number='m00000' and a.town_number='m51000')
where exists (select 1 from t_people_info b
where a.people_number=b.people_number
and a.year='2011' and a.city_number='m00000' and a.town_number='m51000')
--3.281
begin
for crin (select a.rowid,b.join_statefrom t_join_situation a,t_people_info b
where a.people_number=b.people_number
and a.year='2011' and a.city_number='m00000' and a.town_number='m51000')loop
update t_join_situationset join_state=cr.join_statewhere
rowid = cr.rowid;
end loop;
end;
--1.641
merge into t_join_situation a
using t_people_info b
on (a.people_number=b.people_number
and a.year='2011' and a.city_number='m00000' and a.town_number='m51000')
when matched then update set a.join_state=b.join_state
oracle 批量插入不同方案對比
實時測試的速度 48466條資料 1.297 inline view更新法 inline view更新法就是更新乙個臨時建立的檢視 update select a.join stateas join state a,b.join stateas join state b from t join si...
oracle批量插入優化方案
今天聽dba說如果從乙個表批量查詢出一批資料之後批量插入另外一張表的優化方案 1 不寫歸檔日誌 2 採用獨佔 1 不寫日誌設定 2alter table my flosta all 571 nologging 34 insert into my flosta all 571 oid,p day,ci...
oracle批量插入優化方案
今天聽dba說如果從乙個表批量查詢出一批資料之後批量插入另外一張表的優化方案 1 不寫歸檔日誌 2 採用獨佔 1 不寫日誌設定 2alter table my flosta all 571 nologging 34 insert into my flosta all 571 oid,p day,ci...