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

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

系統(tǒng) 3312 0

本系列文章導(dǎo)航

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

[Oracle]高效的PL/SQL程序設(shè)計(jì)(二)--標(biāo)量子查詢(xún)

[Oracle]高效的PL/SQL程序設(shè)計(jì)(三)--Package的優(yōu)點(diǎn)

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

[Oracle]高效的PL/SQL程序設(shè)計(jì)(五)--調(diào)用存儲(chǔ)過(guò)程返回結(jié)果集

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

批量處理一般用在ETL操作, ETL代表提取(extract),轉(zhuǎn)換(transform),裝載(load), 是一個(gè)數(shù)據(jù)倉(cāng)庫(kù)的詞匯!

類(lèi)似于下面的結(jié)構(gòu):

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

一般情況下, 我們處理大筆的數(shù)據(jù)插入動(dòng)作, 有2種做法, 第一種就是一筆筆的循環(huán)插入

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 ;

在性能方面批量處理有著很大的優(yōu)勢(shì), p_array_size一般默認(rèn)都是100

博文來(lái)源: http://blog.csdn.net/huanghui22/archive/2007/05/22/1621290.aspx

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


更多文章、技術(shù)交流、商務(wù)合作、聯(lián)系博主

微信掃碼或搜索:z360901061

微信掃一掃加我為好友

QQ號(hào)聯(lián)系: 360901061

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

【本文對(duì)您有幫助就好】

您的支持是博主寫(xiě)作最大的動(dòng)力,如果您喜歡我的文章,感覺(jué)我的文章對(duì)您有幫助,請(qǐng)用微信掃描上面二維碼支持博主2元、5元、10元、自定義金額等您想捐的金額吧,站長(zhǎng)會(huì)非常 感謝您的哦!!!

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 富顺县| 烟台市| 东乡族自治县| 岐山县| 孝昌县| 灵山县| 安远县| 陇西县| 徐闻县| 建始县| 故城县| 礼泉县| 南开区| 宁乡县| 朝阳市| 芦山县| 武川县| 衡山县| 普安县| 阳城县| 商丘市| 无极县| 辽宁省| 吉安市| 元谋县| 芒康县| 耿马| 石景山区| 辛集市| 广汉市| 衡阳县| 霍林郭勒市| 龙山县| 韶山市| 鹰潭市| 佛学| 兴文县| 上饶市| 微博| 邵东县| 鲁甸县|