日韩久久久精品,亚洲精品久久久久久久久久久,亚洲欧美一区二区三区国产精品 ,一区二区福利

[Oracle]高效的PL/SQL程序設計(四)--批量處理

系統 3061 0

本系列文章導航

[Oracle]高效的PL/SQL程序設計(一)--偽列ROWNUM使用技巧

[Oracle]高效的PL/SQL程序設計(二)--標量子查詢

[Oracle]高效的PL/SQL程序設計(三)--Package的優點

[Oracle]高效的PL/SQL程序設計(四)--批量處理

[Oracle]高效的PL/SQL程序設計(五)--調用存儲過程返回結果集

[Oracle]高效的PL/SQL程序設計(六)--%ROWTYPE的使用

批量處理一般用在ETL操作, ETL代表提取(extract),轉換(transform),裝載(load), 是一個數據倉庫的詞匯!

類似于下面的結構:

for x( select * from ...)
loop
Processdata;
insert into table values (...);
end loop;

一般情況下, 我們處理大筆的數據插入動作, 有2種做法, 第一種就是一筆筆的循環插入

create table t1 as select * from user_tables where 1 = 0 ;
create table t2 as select * from user_tables where 1 = 0 ;
create table t3 as select table_name from user_tables where 1 = 0 ;
create or replace procedure Nor_Test
as
begin
for x in ( select * from user_tables)
loop
insert into t1 values x;
end loop;
end ;

第2種方法就是批量處理(insert全部字段):

create or replace procedure Bulk_Test1(p_array_size in number )
as
typearray
is table of user_tables % rowtype;
l_dataarray;
cursor c is select * from user_tables;
begin
open c;
loop
fetch c bulk collect into l_datalimitp_array_size;

foralli
in 1 ..l_data. count
insert into t2 values l_data(i);

exit when c % notfound;
end loop;
end ;

insert部分字段:

create or replace procedure Bulk_Test2(p_array_size in number )
as
l_tablenamedbms_sql.Varchar2_Table;
cursor c is select table_name from user_tables;
begin
open c;
loop
fetch c bulk collect into l_tablenamelimitp_array_size;

foralli
in 1 ..l_tablename. count
insert into t3 values (l_tablename(i));

exit when c % notfound;
end loop;
end ;

在性能方面批量處理有著很大的優勢, p_array_size一般默認都是100

博文來源: http://blog.csdn.net/huanghui22/archive/2007/05/22/1621290.aspx

[Oracle]高效的PL/SQL程序設計(四)--批量處理


更多文章、技術交流、商務合作、聯系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號聯系: 360901061

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。

【本文對您有幫助就好】

您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長會非常 感謝您的哦!!!

發表我的評論
最新評論 總共0條評論
主站蜘蛛池模板: 榆社县| 江门市| 沈丘县| 潼南县| 绩溪县| 柞水县| 湘西| 新泰市| 福安市| 黎城县| 行唐县| 日喀则市| 沙坪坝区| 华安县| 永济市| 高密市| 交口县| 陇西县| 岱山县| 苗栗市| 高青县| 昆明市| 阳高县| 崇州市| 永靖县| 渝中区| 崇明县| 新郑市| 新津县| 津市市| 确山县| 栖霞市| 巴林右旗| 中宁县| 新竹县| 平乐县| 潮安县| 南阳市| 巴林右旗| 巴楚县| 阜宁县|