當(dāng)前位置:首頁 > IT技術(shù) > 移動(dòng)平臺 > 正文

oracle 中 insert,copy,insert append 執(zhí)行對比
2021-08-09 18:37:53

還是由于遷移數(shù)據(jù)庫,測試了insert,copy,insert append的執(zhí)行速度。


環(huán)境:oracle9i向oracle11g遷移,linux系統(tǒng)。

表已建立,只允許插入數(shù)據(jù),而不能使用create .. select 或 copy .. create。

?

1. 建立dblink,供insert,insert append使用。


2. 登錄11g數(shù)據(jù)庫。并set timing on


3. 建立視圖查看redo size

create redo_size as

select value?
from v$mystat, v$statname?
where v$mystat.statistic# = v$statname.statistic#?
and v$statname.name = 'redo size';


4. insert into dblink_test_tab select * from?tran_rec_03@dblink_test;

?

insert /*+ APPEND */ into dblink_test_tab select * from?tran_rec_03@dblink_test;


copy from?ispay/ispay@crmtest?insert dblink_test_tab using select * from tran_rec_03;


在執(zhí)行以上所有語句前與后執(zhí)行select * from redo_size;


5. 得到的結(jié)果如下:

redo_size 用時(shí)

insert 177821968 4'25"
insert append 3590412 3'15"
copy 124438620 4'20"
數(shù)據(jù)量:495665


結(jié)論:

insert 需要的時(shí)間最多,redo量最大。

insert append 需要的時(shí)間最短,redo量最小。

copy則不需要dblink。

本文摘自 :https://blog.51cto.com/u

開通會(huì)員,享受整站包年服務(wù)立即開通 >