你好!
成都創(chuàng)新互聯(lián)堅(jiān)持“要么做到,要么別承諾”的工作理念,服務(wù)領(lǐng)域包括:網(wǎng)站建設(shè)、成都網(wǎng)站設(shè)計(jì)、企業(yè)官網(wǎng)、英文網(wǎng)站、手機(jī)端網(wǎng)站、網(wǎng)站推廣等服務(wù),滿足客戶于互聯(lián)網(wǎng)時(shí)代的龍灣網(wǎng)站設(shè)計(jì)、移動(dòng)媒體設(shè)計(jì)的需求,幫助企業(yè)找到有效的互聯(lián)網(wǎng)解決方案。努力成為您成熟可靠的網(wǎng)絡(luò)建設(shè)合作伙伴!
一次折騰幾千萬的話,
那么設(shè)置一下,
有
20W了,
就自動(dòng)提交一下。
set
autocommit
on;
set
autocommit
200000;
然后,假如你的目標(biāo)數(shù)據(jù)庫,
是歸檔的話,
可以
INSERT
/*+
append
*/
INTO
目標(biāo)表
nologging
SELECT
*
FROM
源表@DBLINK;
commit;
set
autocommit
off;
假如你的
目標(biāo)表
上面,
有
索引的話,
建議先刪除
索引。
等
上面的
INSERT
語句執(zhí)行完畢后,
再重建索引。
僅代表個(gè)人觀點(diǎn),不喜勿噴,謝謝。
顯式提交和隱式提交
顯式提交,比如出現(xiàn)commit,這類的就是顯式提交。
隱式提交是不用寫commit的提交,比如alter語句的提交。
兩種方式實(shí)現(xiàn)oracle批量提交
方式一:利用 fetch .. bulk collect into .. limit limitnumber;--limitnumber批量提交條數(shù)
declare Cursor dataCursors
is
/*定義游標(biāo)*/
;
type dataCursor is table of tablename%rowtype;
dataCursorP dataCursor;
begin
open dataCursors;
while (true) loop
fetch dataCursors bulk collect into dataCursorP limit 50;
forall i in 1 .. dataCursorP.count
insert into tablename values dataCursorP(i);
commit;
exit when dataCursors%notfound;
end loop;
close dataCursors;
end;
方式二:自己實(shí)現(xiàn)批量提交功能
實(shí)現(xiàn)原理:定義一個(gè)number類型的記錄數(shù),游標(biāo)循環(huán)過程中記錄數(shù)自增1,利用mod判斷如果是否整除,整除就提交。
declare executenum:=0;
declare Cursor dataCursors
is
/*定義游標(biāo)*/
;
dataCursor dataCursors%rowtype;
begin
for dataCursor in dataCursors
loop
executenum:=executenum+1;
/*update,insert or delete 等操作 */
if mod(executenum,50)=0 --這里設(shè)置50條一提交
then commit;
end if;
end loop;
commit;--最后提交一次,因?yàn)橛锌赡茏詈蟛皇?0的整數(shù)
end;
--executenum還可以記錄操作的條數(shù),
QL conn roger/roger
Connected.
SQL create
cluster t_cluster(id number(2)) ;
Cluster created.
SQL create
table t_0610
2 (id number(2)
primary key,
3
name varchar2(13))
4 cluster t_cluster(id);
Table
created.
SQL create
index t_cluster_idx
on cluster t_cluster;
Index
created.
SQL
SQL insert
into t_0610 values(1,'baidu');
1 row created.
SQL insert
into t_0610 values(2,'google');
1 row created.
SQL insert
into t_0610 values(8,'roger');
1 row created.
SQL commit;
重新啟動(dòng)時(shí),系統(tǒng)先REDO,然后對未提交的UNDO,數(shù)據(jù)在更新前的狀態(tài)
這個(gè)commit應(yīng)該是本機(jī)的,和dblink沒什么關(guān)系,而且就算你找到的dblink的那個(gè)session那么也不行,以為這個(gè)session在dblink的操作完成后已經(jīng)關(guān)閉了。
個(gè)人感覺不要這么遠(yuǎn)程insert,最好是調(diào)用一個(gè)那個(gè)數(shù)據(jù)庫上的過程去insert這樣的話,在那個(gè)過程中commit肯定是沒有問題的。
如果必須要這么寫,那么可以加入一條insert和一條delete
就是上面是正常insert的語句。
下面有一條delete(這條刪除一個(gè)絕對不可能出現(xiàn)的一條試試)
按照你的說法,第二個(gè)事務(wù)提交時(shí),第一個(gè)事務(wù)才能commit??墒沁@樣會(huì)出現(xiàn)問題,因?yàn)槿绻愦罅刻峤唬敲磾?shù)據(jù)庫會(huì)因此夯住的,所以你看看第一個(gè)辦法行不行,我覺得第一個(gè)辦法還靠譜點(diǎn)。
新聞標(biāo)題:oracle怎么提交 oracle提交事務(wù)的sql語句
當(dāng)前URL:http://www.muchs.cn/article40/hhiceo.html
成都網(wǎng)站建設(shè)公司_創(chuàng)新互聯(lián),為您提供全網(wǎng)營銷推廣、電子商務(wù)、網(wǎng)站改版、品牌網(wǎng)站設(shè)計(jì)、網(wǎng)頁設(shè)計(jì)公司、網(wǎng)站制作
聲明:本網(wǎng)站發(fā)布的內(nèi)容(圖片、視頻和文字)以用戶投稿、用戶轉(zhuǎn)載內(nèi)容為主,如果涉及侵權(quán)請盡快告知,我們將會(huì)在第一時(shí)間刪除。文章觀點(diǎn)不代表本網(wǎng)站立場,如需處理請聯(lián)系客服。電話:028-86922220;郵箱:631063699@qq.com。內(nèi)容未經(jīng)允許不得轉(zhuǎn)載,或轉(zhuǎn)載時(shí)需注明來源: 創(chuàng)新互聯(lián)