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

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

系統(tǒng) 3276 0

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

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

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

[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ù)的詞匯!

類似于下面的結(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

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

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

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

發(fā)表我的評(píng)論
最新評(píng)論 總共0條評(píng)論
主站蜘蛛池模板: 老河口市| 定西市| 阜阳市| 湛江市| 翼城县| 勐海县| 将乐县| 长沙市| 改则县| 科尔| 昌平区| 五家渠市| 长治市| 互助| 奉贤区| 兴城市| 明星| 酒泉市| 济阳县| 宁安市| 两当县| 寿光市| 留坝县| 滨州市| 东丽区| 新野县| 桦南县| 思南县| 方城县| 观塘区| 西峡县| 昌宁县| 喀什市| 莲花县| 万盛区| 德令哈市| 元朗区| 安国市| 射阳县| 宝丰县| 疏附县|