{"id":188,"date":"2019-09-18T19:09:41","date_gmt":"2019-09-18T11:09:41","guid":{"rendered":"https:\/\/blog.dbtopas.com\/?p=188"},"modified":"2019-09-20T11:50:51","modified_gmt":"2019-09-20T03:50:51","slug":"oracle%e4%b8%ad%e5%a6%82%e4%bd%95%e6%9b%b4%e6%96%b0%e4%b8%80%e5%bc%b5%e5%a4%a7%e8%a1%a8%e8%a8%98%e9%8c%84","status":"publish","type":"post","link":"https:\/\/blog.dbtopas.com\/?p=188","title":{"rendered":"Oracle\u4e2d\u5982\u4f55\u66f4\u65b0\u4e00\u5f35\u5927\u8868\u8a18\u9304"},"content":{"rendered":"<p><a href=\"https:\/\/read01.com\/archive\/20150603\/\">2015\/06\/03<\/a>\u00a0\u4f86\u6e90\uff1aITPUB<\/p>\n<p>\u539f\u6587\u7db2\u5740\uff1a<a href=\"https:\/\/read01.com\/BnK7jG.html\" target=\"_blank\" rel=\"noopener noreferrer\">https:\/\/read01.com\/BnK7jG.html<\/a><\/p>\n<p>SQL\u8a9e\u53e5\u662f\u4e00\u7a2e\u65b9\u4fbf\u7684\u8a9e\u8a00\uff0c\u540c\u6a23\u4e5f\u662f\u4e00\u7a2e\u300c\u8ff7\u60d1\u6027\u300d\u7684\u8a9e\u8a00\u3002\u9019\u500b\u4e3b\u8981\u9ad4\u73fe\u5728\u5b83\u7684\u96c6\u5408\u64cd\u4f5c\u7279\u6027\u4e0a\u3002\u7121\u8ad6\u6578\u64da\u8868\u6578\u64da\u91cf\u662f1\u689d\uff0c\u9084\u662f1\u5104\u689d\uff0c\u66f4\u65b0\u7684\u8a9e\u53e5\u90fd\u662f\u5b8c\u5168\u76f8\u540c\u3002\u4f46\u662f\uff0c\u5be6\u969b\u57f7\u884c\u7d50\u679c\uff08\u6216\u8005\u80fd\u5426\u51fa\u73fe\u7d50\u679c\uff09\u537b\u662f\u6709\u5f88\u5927\u7684\u5dee\u7570\u3002<\/p>\n<p>\u7b46\u8005\u5728\u958b\u767cDBA\u9818\u57df\u7684\u4e00\u500b\u7406\u5ff5\u662f\uff1a\u4f5c\u70ba\u958b\u767c\u4eba\u54e1\uff0c\u5c0d\u8cc7\u6599\u5eab\u3001\u5c0d\u6578\u64da\u8981\u6709\u656c\u754f\u4e4b\u5fc3\uff0c\u4e00\u500b\u8a9e\u53e5\u767c\u51fa\u4e4b\u524d\uff0c\u8d77\u78bc\u8981\u8003\u616e\u5169\u500b\u554f\u984c\uff1a\u76ee\u6a19\u6578\u64da\u8868\u7684\u7e3d\u6578\u64da\u91cf\u662f\u591a\u5c11\uff08\u6295\u7522\u4e4b\u5f8c\uff09\uff1f\u4f60\u9019\u500b\u64cd\u4f5c\u6703\u6d89\u53ca\u5230\u591a\u5927\u7684\u6578\u64da\u91cf\uff1f\u4e0d\u540c\u7684\u56de\u7b54\uff0c\u8655\u7406\u7684\u65b9\u6848\u5176\u5be6\u662f\u4e0d\u540c\u7684\u3002<\/p>\n<p><!--more--><\/p>\n<p>\u66f4\u65b0\u5927\u8868\u6578\u64da\uff0c\u662f\u6211\u5011\u5728\u958b\u767c\u548c\u904b\u7dad\uff0c\u7279\u5225\u662f\u5728\u6578\u64da\u9077\u79fb\u9818\u57df\u7d93\u5e38\u9047\u5230\u7684\u4e00\u7a2e\u5834\u666f\u3002\u4e0a\u9762\u5169\u500b\u554f\u984c\u7684\u56de\u7b54\u662f\uff1a\u76ee\u6a19\u6578\u64da\u8868\u6574\u9ad4\u5c31\u5f88\u5927\uff0c\u800c\u4e14\u66f4\u65b0\u7bc4\u570d\u4e5f\u5f88\u5927\u3002\u4e00\u500bSQL\u5f9e\u7406\u8ad6\u4e0a\u53ef\u4ee5\u8655\u7406\u3002\u4f46\u662f\u5728\u5be6\u969b\u4e2d\uff0c\u9019\u7a2e\u65b9\u6848\u6703\u6709\u5f88\u591a\u554f\u984c\u3002<\/p>\n<p>\u672c\u7bc7\u4e3b\u8981\u4ecb\u7d39\u5e7e\u7a2e\u5e38\u898b\u7684\u5927\u8868\u8655\u7406\u7b56\u7565\uff0c\u4e26\u4e14\u5206\u6790\u51fa\u4ed6\u5011\u7684\u512a\u52a3\u3002\u4f5c\u70ba\u6211\u5011\u958b\u767c\u4eba\u54e1\u548cDBA\uff0c\u9078\u53d6\u7684\u6a19\u6e96\u4e5f\u662f\u9748\u6d3b\u7684\uff1a\u6839\u64da\u4f60\u7684\u64cd\u4f5c\u985e\u578b\uff08\u904b\u7dad\u64cd\u4f5c\u9084\u662f\u7cfb\u7d71\u65e5\u5e38\u4f5c\u696d\uff09\u3001\u7a0b\u5e8f\u904b\u884c\u74b0\u5883\uff08\u786c\u9ad4\u74b0\u5883\u662f\u5426\u652f\u6301\u4e26\u884c\uff09\u548c\u7a0b\u5e8f\u8a2d\u8a08\u74b0\u5883\uff08\u662f\u5426\u53ef\u4ee5\u5b8c\u5168\u7368\u5360\u6240\u6709\u8cc7\u6e90\uff09\u4f86\u7d9c\u5408\u8003\u91cf\u6c7a\u5b9a\u3002<\/p>\n<p>\u9996\u5148\uff0c\u6211\u5011\u9700\u8981\u6e96\u5099\u51fa\u4e00\u5f35\u5927\u8868\u3002<\/p>\n<p>1\u3001\u74b0\u5883\u6e96\u5099<\/p>\n<p>\u6211\u5011\u9078\u64c7Oracle 11.2\u7248\u672c\u9032\u884c\u8a66\u9a57\u3002<\/p>\n<p>SQL&gt; select * from v$version;<\/p>\n<p>BANNER<\/p>\n<p>Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 &#8211; Production<\/p>\n<p>PL\/SQL Release 11.2.0.1.0 &#8211; Production<\/p>\n<p>CORE 11.2.0.1.0 Production<\/p>\n<p>TNS for Linux: Version 11.2.0.1.0 &#8211; Production<\/p>\n<p>NLSRTL Version 11.2.0.1.0 \u2013 Production<\/p>\n<p>\u6e96\u5099\u4e00\u5f35\u5927\u8868\u3002<\/p>\n<p>SQL&gt; create table t as select * from dba_objects;<\/p>\n<p>Table created<\/p>\n<p>SQL&gt; insert into t select * from t;<\/p>\n<p>72797 rows inserted<\/p>\n<p>SQL&gt; insert into t select * from t;<\/p>\n<p>145594 rows inserted<\/p>\n<p>SQL&gt; commit;<\/p>\n<p>Commit complete<\/p>\n<p>SQL&gt; select bytes\/1024\/1024\/1024 from dba_segments where owner=&#8217;SYS&#8217; and segment_name=&#8217;T&#8217;;<\/p>\n<p>BYTES\/1024\/1024\/1024<\/p>\n<p>1.0673828125<\/p>\n<p>SQL&gt; select count(*) from t;<\/p>\n<p>COUNT(*)<\/p>\n<p>9318016<\/p>\n<p>Executed in 14.711 seconds<\/p>\n<p>\u6578\u64da\u8868T\u4f5c\u70ba\u6578\u64da\u4f86\u6e90\uff0c\u4e00\u5171\u5305\u62ec9\u767e\u591a\u842c\u689d\u8a18\u9304\uff0c\u5408\u8a08\u7a7a\u95931G\u5de6\u53f3\u3002\u7b46\u8005\u5be6\u9a57\u74b0\u5883\u662f\u5728\u865b\u64ec\u6a5f\u4e0a\uff0c\u4e00\u9846\u865b\u64ecCPU\uff0c\u6240\u4ee5\u5f8c\u9762\u9032\u884c\u4e26\u884cParallel\u64cd\u4f5c\u7684\u65b9\u6848\u5c31\u662f\u793a\u610f\u6027\u8cea\uff0c\u4e0d\u5177\u6709\u4ee3\u8868\u6027\u3002<\/p>\n<p>\u4e0b\u9762\u6211\u5011\u4f86\u770b\u6700\u7c21\u55ae\u7684\u4e00\u7a2e\u65b9\u6cd5\uff0c\u76f4\u63a5update\u3002<\/p>\n<p>2\u3001\u65b9\u6cd51\uff1a\u76f4\u63a5Update<\/p>\n<p>\u6700\u7c21\u55ae\uff0c\u4e5f\u662f\u6700\u5bb9\u6613\u51fa\u554f\u984c\u7684\u65b9\u6cd5\uff0c\u5c31\u662f\u300c\u4e0d\u7ba1\u4e09\u4e03\u4e8c\u5341\u4e00\u300d\uff0c\u76f4\u63a5update\u6578\u64da\u8868\u3002\u5373\u4f7f\u5f88\u591a\u8001\u7a0b\u5f0f\u8a2d\u8a08\u5e2b\u548cDBA\uff0c\u4e5f\u7e3d\u662f\u9078\u64c7\u51fa\u9019\u6a23\u7684\u7b56\u7565\u65b9\u6cd5\u3002\u5176\u5be6\uff0c\u5373\u4f7f\u7d50\u679c\u80fd\u51fa\u4f86\uff0c\u4e5f\u6709\u5f88\u5927\u7684\u50e5\u5016\u6210\u5206\u5728\u5176\u4e2d\u3002<\/p>\n<p>\u6211\u5011\u9996\u5148\u770b\u7b46\u8005\u7684\u5be6\u9a57\uff0c\u4e4b\u5f8c\u8a0e\u8ad6\u5176\u4e2d\u7684\u539f\u56e0\u3002\u5148\u5275\u5efa\u4e00\u5f35\u5be6\u9a57\u6578\u64da\u8868t_target\u3002<\/p>\n<p>SQL&gt; create table t_targettablespace users as select * from t;<\/p>\n<p>Table created<\/p>\n<p>SQL&gt; update t_target set owner=to_char(length(owner));<\/p>\n<p>\uff08\u9577\u6642\u9593\u7b49\u5f85\u2026\u2026\uff09<\/p>\n<p>\u5728\u7b49\u5f85\u671f\u9593\uff0c\u7b46\u8005\u767c\u73fe\u5982\u4e0b\u5e7e\u500b\u73fe\u8c61\uff1a<\/p>\n<p>\u00fc \u8cc7\u6599\u5eab\u4f3a\u670d\u5668\u904b\u884c\u901f\u5ea6\u5947\u6162\uff0c\u5f88\u591a\u9023\u63a5\u64cd\u4f5c\u901f\u5ea6\u6e1b\u7de9\uff0c\u4e00\u6bb5\u6642\u9593\u751a\u81f3\u7121\u6cd5\u767b\u9678\uff1b<\/p>\n<p>\u00fc \u5f8c\u53f0\u6703\u8a71\u7b49\u5f85\u6642\u9593\u96c6\u4e2d\u5728\u6578\u64da\u8b80\u53d6\u3001log space buffer\u3001\u7a7a\u9593\u5206\u914d\u7b49\u4e8b\u4ef6\u4e0a\uff1b<\/p>\n<p>\u00fc \u9577\u671f\u7b49\u5f85\uff0c\u4f5c\u696d\u7cfb\u7d71\u5c64\u9762\u958b\u59cb\u51fa\u73fe\u7570\u5e38\u3002Undo\u8868\u7a7a\u9593\u81a8\u8139\uff1b<\/p>\n<p>\u00fc \u65e5\u8a8c\u5207\u63db\u983b\u7e41\uff1b<\/p>\n<p>\u6b64\u5916\uff0c\u9078\u64c7\u9019\u6a23\u7b56\u7565\u7684\u670b\u53cb\u9084\u53ef\u80fd\u9047\u5230\uff1a\u524d\u53f0\u932f\u8aa4\u62cb\u51fa\u7570\u5e38\u3001\u5ba2\u6236\u7aef\u9023\u63a5\u88ab\u65b7\u958b\u7b49\u7b49\u73fe\u8c61\u3002<\/p>\n<p>\u7b46\u8005\u9047\u5230\u9019\u6a23\u7684\u5834\u666f\u4e5f\u662f\u6bd4\u8f03\u7cfe\u7d50\uff0c\u9996\u5148\uff0c\u9577\u6642\u9593\u7b49\u5f85\uff08\u751a\u81f3\u4e00\u591c\uff09\u53ef\u80fd\u6700\u7d42\u6c92\u6709\u4efb\u4f55\u7d50\u679c\u3002\u6700\u8981\u547d\u7684\u662f\u4e5f\u4e0d\u6562\u8f15\u6613\u7684\u64a4\u92b7\u64cd\u4f5c\uff0c\u56e0\u70baOracle\u8981\u9032\u884cupdate\u64cd\u4f5c\u7684\u56de\u6efe\u52d5\u4f5c\u3002\u4e00\u500b\u5c0f\u6642\u4e4b\u5f8c\uff0c\u7b46\u8005\u653e\u68c4\u3002<\/p>\n<p>updatet_target set owner=to_char(length(owner))<\/p>\n<p>ORA-01013:\u7528\u6236\u8acb\u6c42\u53d6\u6d88\u7576\u524d\u7684\u64cd\u4f5c<\/p>\n<p>\uff08\u63a5\u8fd1\u4e00\u5c0f\u6642\u672a\u5b8c\u6210\uff09<\/p>\n<p>\u4e4b\u5f8c\u5c31\u662f\u76f8\u540c\u6642\u9593\u7684rollback\u7b49\u5f85\uff0c\u901a\u5e38\u662f\u4e8b\u52d9\u57f7\u884c\u904e\u591a\u9577\u6642\u9593\uff0c\u56de\u6efe\u9032\u884c\u591a\u9577\u6642\u9593\u3002\u671f\u9593\uff0c\u53ef\u4ee5\u901a\u904ex$ktuxe\u5f8c\u53f0\u5167\u90e8\u8868\u4f86\u89c0\u5bdf\u3001\u6e2c\u7b97\u56de\u6efe\u901f\u5ea6\u3002\u9019\u500b\u904e\u7a0b\u4e2d\uff0c\u6211\u5011\u53ea\u6709\u300c\u4e56\u4e56\u7b49\u5f85\u300d\u3002<\/p>\n<p>SQL&gt; select KTUXESIZ from x$ktuxe where KTUXESTA&lt;&gt;&#8217;INACTIVE&#8217;;<\/p>\n<p>KTUXESIZ<\/p>\n<p>62877<\/p>\n<p>\uff08\u2026\u2026\uff09<\/p>\n<p>KTUXESIZ<\/p>\n<p>511<\/p>\n<p>\u7d9c\u5408\u9019\u7a2e\u7b56\u7565\u7684\u7d50\u679c\u901a\u5e38\u662f\uff1a\u540c\u696d\u62b1\u6028\uff08\u5f71\u97ff\u4e86\u4ed6\u5011\u7684\u4f5c\u696d\u57f7\u884c\uff09\u3001\u63d0\u5fc3\u5f14\u81bd\uff08\u4e0d\u77e5\u9053\u57f7\u884c\u5230\u54ea\u88e1\u4e86\uff09\u3001\u8cc7\u6e90\u8017\u76e1\uff08CPU\u3001\u5167\u5b58\u6216\u8005IO\u5360\u5230\u6eff\uff09\u3001\u52de\u800c\u7121\u529f\uff08\u6700\u5f8c\u9084\u662f\u88abrollback\uff09\u3002\u5982\u679c\u662f\u6b63\u5f0f\u6295\u7522\u74b0\u5883\uff0c\u9084\u8981\u627f\u64d4\u5f71\u97ff\u696d\u52d9\u751f\u7522\u7684\u8cac\u4efb\u3002<\/p>\n<p>\u6211\u5011\u8a73\u7d30\u5206\u6790\u4e00\u4e0b\u9019\u7a2e\u7b56\u7565\u7684\u554f\u984c\uff1a<\/p>\n<p>\u9996\u5148\uff0c\u6211\u5011\u9700\u8981\u627f\u8a8d\u9019\u7a2e\u65b9\u5f0f\u7684\u512a\u9ede\uff0c\u5c31\u662f\u7c21\u55ae\u548c\u7247\u9762\u7684\u9ad8\u6548\u3002\u76f8\u5c0d\u65bc\u5728\u672c\u6587\u4e2d\u5176\u4ed6\u4ecb\u7d39\u7684\u65b9\u6cd5\uff0c\u9019\u7a2e\u65b9\u5f0f\u4ee3\u78bc\u91cf\u662f\u6700\u5c11\u7684\u3002\u800c\u4e14\uff0c\u9019\u7a2e\u65b9\u6cd5\u4e00\u6b21\u6027\u7684\u5c07\u6240\u6709\u7684\u4efb\u52d9\u63d0\u4ea4\u7d66\u8cc7\u6599\u5eabSQL\u5f15\u64ce\uff0c\u53ef\u4ee5\u6700\u5927\u7a0b\u5ea6\u7684\u767c\u63ee\u7cfb\u7d71\u4e00\u500b\u65b9\u9762\uff08CPU\u3001IO\u6216\u8005\u5167\u5b58\uff09\u7684\u80fd\u529b\u3002<\/p>\n<p>\u5982\u679c\u6211\u5011\u7684\u6578\u64da\u8868\u6bd4\u8f03\u5c0f\uff0c\u7d93\u9a57\u503c\u5728\u5e7e\u842c\u4e00\u4e0b\uff0c\u9019\u7a2e\u65b9\u6cd5\u662f\u6bd4\u8f03\u5408\u9069\u7684\u3002\u6211\u5011\u53ef\u4ee5\u8003\u616e\u4f7f\u7528\u3002<\/p>\n<p>\u53e6\u4e00\u65b9\u9762\uff0c\u6211\u5011\u8981\u770b\u5230Oracle Update\u7684\u53e6\u4e00\u500b\u65b9\u9762\uff0c\u5c31\u662fUndo\u3001Redo\u548c\u9032\u7a0b\u5de5\u4f5c\u8ca0\u8f09\u7684\u554f\u984c\u3002\u719f\u6089Oracle\u7684\u670b\u53cb\u5011\u77e5\u9053\uff0c\u5728DML\u64cd\u4f5c\u7684\u6642\u5019\uff0cUndo\u548cRedo\u662f\u975e\u5e38\u91cd\u8981\u7684\u65b9\u9762\u3002\u7576\u6211\u5011\u5728Update\u548cDelete\u6578\u64da\u7684\u6642\u5019\uff0c\u6578\u64da\u584a\u88ab\u4fee\u6539\u4e4b\u524d\u7684\u300c\u524d\u93e1\u50cf\u300d\u5c31\u6703\u4fdd\u5b58\u5728Undo Tablespace\u88e1\u9762\u3002\u6ce8\u610f\uff1aUndo Tablespace\u662f\u4e00\u7a2e\u7279\u6b8a\u7684\u8868\u7a7a\u9593\uff0c\u9700\u8981\u4fdd\u5b58\u5728\u78c1\u789f\u4e0a\u3002Undo\u7684\u5b58\u5728\u4e3b\u8981\u662f\u70ba\u4e86\u652f\u6301\u8cc7\u6599\u5eab\u5176\u4ed6\u6703\u8a71\u7684\u300c\u4e00\u81f4\u8b80\u300d\u64cd\u4f5c\u3002\u53ea\u8981\u4e8b\u52d9\u6c92\u6709\u88abcommit\u6216\u8005rollback\uff0cUndo\u6578\u64da\u5c31\u6703\u4e00\u76f4\u4fdd\u7559\u5728\u8cc7\u6599\u5eab\u4e2d\uff0c\u800c\u4e14\u4e0d\u80fd\u88ab\u300c\u8986\u84cb\u300d\u3002<\/p>\n<p>Redo\u8a18\u9304\u4e86\u9032\u884cDML\u64cd\u4f5c\u7684\u300c\u5f8c\u93e1\u50cf\u300d\uff0cRedo\u751f\u6210\u662f\u548c\u6211\u5011\u4fee\u6539\u7684\u6578\u64da\u91cf\u76f8\u95dc\u3002\u73fe\u5be6\u554f\u984c\u8981\u4fee\u6539\u591a\u5c11\u689d\u8a18\u9304\uff0c\u751f\u6210\u7684Redo\u7e3d\u91cf\u662f\u4e0d\u8b8a\u7684\uff0c\u9664\u975e\u6211\u5011\u5617\u8a66nologging\u9078\u9805\u3002Redo\u55ae\u500b\u65e5\u8a8c\u6210\u54e1\u5982\u679c\u6bd4\u8f03\u5c0f\uff0cOracle\u61c9\u7528\u751f\u6210Redo\u901f\u5ea6\u6bd4\u8f03\u5927\u3002Redo Group\u5207\u63db\u983b\u5ea6\u9ad8\uff0c\u7cfb\u7d71\u4e2d\u5c31\u9762\u81e8\u8457\u5927\u91cf\u7684\u65e5\u8a8c\u5207\u63db\u6216\u8005Log Space Buffer\u76f8\u95dc\u7684\u7b49\u5f85\u4e8b\u4ef6\u3002<\/p>\n<p>\u5982\u679c\u6211\u5011\u9078\u64c7\u7b2c\u4e00\u7a2e\u65b9\u6cd5\uff0cUndo\u8868\u7a7a\u9593\u5c31\u662f\u4e00\u500b\u5f88\u5927\u7684\u74f6\u9838\u3002\u5927\u91cf\u7684\u524d\u93e1\u50cf\u6578\u64da\u4fdd\u5b58\u5728Undo\u8868\u7a7a\u9593\u4e2d\u4e0d\u80fd\u91cb\u653e\uff0c\u7e7c\u800c\u4e0d\u65b7\u7684\u5f15\u8d77Undo\u6587\u4ef6\u81a8\u8139\u3002\u5982\u679cUndo\u6587\u4ef6\u4e0d\u5141\u8a31\u81a8\u8139\uff08autoextend=no\uff09\uff0cOracle DML\u64cd\u4f5c\u6703\u5728\u4e00\u5b9a\u6642\u5019\u5831\u932f\u3002\u5373\u4f7f\u5141\u8a31\u9032\u884c\u81a8\u8139\uff0c\u4e5f\u6703\u4f34\u96a8\u5927\u91cf\u7684\u6578\u64da\u6587\u4ef6DBWR\u5beb\u5165\u52d5\u4f5c\u3002\u9019\u4e5f\u5c31\u662f\u6211\u5011\u5728\u9032\u884c\u5927\u91cfupdate\u7684\u6642\u5019\uff0c\u5728event\u7b49\u5f85\u4e8b\u4ef6\u4e2d\u80fd\u770b\u5230\u5f88\u591a\u7684DBWR\u5beb\u5165\u3002\u56e0\u70ba\uff0c\u9019\u4e9b\u5beb\u5165\u4e2d\uff0c\u4e0d\u4e00\u5b9a\u90fd\u662f\u66f4\u65b0\u4f60\u7684\u6578\u64da\u8868\uff0c\u88e1\u9762\u5f88\u591a\u90fd\u662fUndo\u8868\u7a7a\u9593\u5beb\u5165\u3002<\/p>\n<p>\u540c\u6642\uff0c\u9577\u6642\u9593\u7684\u7b49\u5f85\u64cd\u4f5c\uff0c\u89f8\u52d5Oracle\u548cOS\u7684\u8ca0\u8f09\u4e0a\u9650\uff0c\u5f88\u591a\u5947\u602a\u7684\u4e8b\u60c5\u4e5f\u53ef\u80fd\u51fa\u73fe\u3002\u6bd4\u5982\u9032\u7a0b\u50f5\u6b7b\u3001\u9023\u63a5\u88ab\u65b7\u958b\u3002<\/p>\n<p>\u9019\u7a2e\u65b9\u5f0f\u6700\u5927\u7684\u554f\u984c\u5728\u65bcrollback\u52d5\u4f5c\u3002\u5982\u679c\u6211\u5011\u5728\u9577\u6642\u9593\u7684\u4e8b\u52d9\u904e\u7a0b\u4e2d\uff0c\u767c\u751f\u4e00\u4e9b\u7570\u5e38\u5831\u932f\uff0c\u901a\u5e38\u662f\u7531\u65bc\u6578\u64da\u7570\u5e38\uff0c\u6574\u500b\u6578\u64da\u9700\u8981\u56de\u6efe\u3002\u56de\u6efe\u662fOracle\u81ea\u6211\u4fdd\u8b77\uff0c\u7dad\u6301\u4e8b\u52d9\u5b8c\u6574\u6027\u7684\u5de5\u5177\u3002\u7576\u4e00\u500b\u9577\u671fDML update\u52d5\u4f5c\u767c\u751f\uff0c\u4e2d\u65b7\u7684\u6642\u5019\uff0cOracle\u5c31\u6703\u9032\u5165\u81ea\u6211\u7684rollback\u968e\u6bb5\uff0c\u76f4\u81f3\u6700\u5f8c\u5b8c\u6210\u3002\u9019\u500b\u904e\u7a0b\u4e2d\uff0c\u7cfb\u7d71\u662f\u6bd4\u8f03\u904b\u884c\u7de9\u6162\u7684\u3002\u5373\u4f7f\u91cd\u555f\u4f3a\u670d\u5668\uff0crollback\u904e\u7a0b\u4e5f\u6703\u5b8c\u6210\u3002<\/p>\n<p>\u6240\u4ee5\uff0c\u9019\u7a2e\u65b9\u6cd5\u5728\u8655\u7406\u5927\u8868\u7684\u6642\u5019\uff0c\u4e00\u5b9a\u8981\u614e\u7528\uff01\uff01\u8d77\u78bc\u8981\u8a55\u4f30\u4e00\u4e0b\u98a8\u96aa\u3002<\/p>\n<p>3\u3001\u65b9\u6cd52\uff1aPL\/SQL\u533f\u540d\u584a<\/p>\n<p>\u4e0a\u9762\u65b9\u6cd51\u7684\u6700\u5927\u554f\u984c\u5728\u65bc\u300c\u4e00\u6b21\u6027\u77ac\u9593\u58d3\u529b\u300d\u5927\u3002\u7121\u8ad6\u662fUndo\u91cf\u3001\u9084\u662fRollback\u91cf\uff0c\u90fd\u662f\u6709\u5f88\u5927\u7684\u554f\u984c\u3002\u5373\u4f7f\u6211\u5011\u7684\u7cfb\u7d71\u80fd\u5920\u652f\u6301\u9019\u6a23\u7684\u64cd\u4f5c\uff0c\u5982\u679cupdate\u904e\u7a0b\u4e2d\u5b58\u5728\u5176\u4ed6\u7684\u4f5c\u696d\uff0c\u5fc5\u7136\u53d7\u5230\u5f71\u97ff\u3002<\/p>\n<p>PL\/SQL\u533f\u540d\u584a\u7684\u539f\u5247\u5728\u65bc\u5e73\u7a69\u8ca0\u8f09\uff0c\u5206\u6279\u7684\u9032\u884c\u8655\u7406\u3002\u9019\u500b\u904e\u7a0b\u9700\u8981\u4f7f\u7528bulk collect\u6279\u91cf\u64cd\u4f5c\uff0c\u9032\u884c\u6e38\u6a19\u64cd\u4f5c\u3002<\/p>\n<p>\u6211\u5011\u9996\u5148\u9084\u539f\u5be6\u9a57\u74b0\u5883\u3002<\/p>\n<p>SQL&gt; truncate table t_target;<\/p>\n<p>Table truncated<\/p>\n<p>SQL&gt; insert \/*+append*\/into t_target select * from t;<\/p>\n<p>9318016 rows inserted<\/p>\n<p>\u4ee3\u78bc\u7247\u6bb5\u3002<\/p>\n<p>SQL&gt; set timing on;<\/p>\n<p>SQL&gt; declare<\/p>\n<p>2 type rowid_list is table of urowid index by binary_integer;<\/p>\n<p>3 rowid_infosrowid_list;<\/p>\n<p>4 i number;<\/p>\n<p>5 cursor c_rowids is select rowid from t_target;<\/p>\n<p>6 begin<\/p>\n<p>7 open c_rowids;<\/p>\n<p>8<\/p>\n<p>9 loop<\/p>\n<p>10 fetch c_rowidsbulk collect into rowid_infos limit2000;<\/p>\n<p>11<\/p>\n<p>12 foralli in 1..rowid_infos.count<\/p>\n<p>13 update t_target set owner=to_char(length(owner)+1)<\/p>\n<p>14 whererowid=rowid_infos(i);<\/p>\n<p>15<\/p>\n<p>16 commit;<\/p>\n<p>17 exit when rowid_infos.count&lt;2000;<\/p>\n<p>18 end loop;<\/p>\n<p>19 close c_rowids;<\/p>\n<p>20 end;<\/p>\n<p>21 \/<\/p>\n<p>PL\/SQL procedure successfully completed<\/p>\n<p>Executed in977.081seconds<\/p>\n<p>\u6211\u5011\u5728977s\u5b8c\u6210\u4e86\u6574\u500b\u64cd\u4f5c\u3002\u9019\u500b\u65b9\u6cd5\u6709\u5e7e\u500b\u7279\u9ede\uff1a\u9996\u5148\u662f\u6279\u91cf\u7684\u7372\u53d6bulk collect\u6307\u5b9a\u6578\u91cf\u66f4\u65b0\u6279\u91cf\u3002\u7b2c\u4e8c\u500b\u662f\u4f7f\u7528forall\u7684\u65b9\u6cd5\u6279\u91cf\u66f4\u65b0\uff0c\u6e1b\u5c11\u5f15\u64ce\u4e4b\u9593\u7684\u5207\u63db\u3002\u7b2c\u4e09\u662f\u66f4\u65b0\u4e00\u6279\u4e4b\u5f8c\uff0ccommit\u64cd\u4f5c\u3002<\/p>\n<p>\u9019\u6a23\u7684\u597d\u8655\u5728\u65bc\u5e73\u7a69\u5316undo\u4f7f\u7528\u3002\u5982\u679c\u6578\u64da\u91cf\u5c11\uff0c\u9019\u7a2e\u4ee3\u78bc\u65b9\u6cd5\u53ef\u80fd\u6bd4\u76f4\u63a5update\u8981\u6162\u3002\u4f46\u662f\u5982\u679c\u6578\u64da\u91cf\u5927\uff0c\u7279\u5225\u662f\u6d77\u91cf\u6578\u64da\u60c5\u6cc1\u4e0b\uff0c\u9019\u7a2e\u65b9\u6cd5\u662f\u53ef\u4ee5\u652f\u6301\u975e\u5e38\u5927\u7684\u6578\u64da\u8868\u66f4\u65b0\u7684\u3002<\/p>\n<p>\u4ee3\u78bc\u4e2dupdate\u64cd\u4f5c\uff0c\u4f7f\u7528rowid\uff0c\u5982\u679c\u6709\u5176\u4ed6\u696d\u52d9\u65b9\u9762\u7684\u4e3b\u9375\u4e5f\u53ef\u4ee5\u4f7f\u7528\u66ff\u63db\u3002<\/p>\n<p>\u5728\u7de8\u7a0b\u5be6\u8e10\u4e2d\uff0c\u6709\u6642\u5019\u6211\u5011\u53ef\u80fd\u4e0d\u80fd\u4f7f\u7528PL\/SQL\u4ee3\u78bc\u7247\u6bb5\uff0c\u53ea\u80fd\u4f7f\u7528SQL\u8a9e\u53e5\u3002\u9019\u7a2e\u6642\u5019\u5c31\u9700\u8981\u7d50\u5408\u696d\u52d9\u65b9\u9762\u6709\u6c92\u6709\u7279\u9ede\u53ef\u4ee5\u4f7f\u7528\uff1f\u9019\u7a2e\u6642\u5019\u5f80\u5f80\u4e5f\u5c31\u8003\u9a57\u958b\u767c\u4eba\u54e1\u5c0d\u696d\u52d9\u7279\u9ede\u7684\u7406\u89e3\u4e86\u3002<\/p>\n<p>\u5728\u4f7f\u7528forall\u7684\u6642\u5019\uff0c\u8981\u6ce8\u610f\u4e00\u6279\u66f4\u65b0\u7684\u6578\u91cf\u3002\u6839\u64da\u4e00\u4e9bOracle\u6587\u737b\u900f\u9732\uff0c\u5167\u90e8SQL\u5f15\u64ce\u5728update\u7684\u6642\u5019\uff0c\u4e5f\u662f\u5206\u6279\u9032\u884c\u7684\uff0c\u6bcf\u6279\u5927\u7d041000\u689d\u8a18\u9304\u3002\u7d93\u9a57\u544a\u8a34\u6211\u5011\u6bcf\u6279\u6578\u91cf\u57281-5\u842c\u6bd4\u8f03\u5408\u9069\u3002<\/p>\n<p>\u9019\u662f\u7b2c\u4e8c\u7a2e\u65b9\u6cd5\uff0c\u4e0b\u9762\u6211\u5011\u4ecb\u7d39\u4e00\u7a2e\u7c21\u55ae\u3001\u53ef\u884c\u7684\u624b\u6bb5\uff0c\u6bd4\u8f03\u65b9\u4fbf\u3002<\/p>\n<p>4\u3001\u65b9\u6cd53\uff1ainsert append\u65b9\u6cd5<\/p>\n<p>\u5f9eUndo\u548cRedo\u7684\u89d2\u5ea6\u770b\uff0c\u6211\u5011\u66f4\u559c\u6b61insert\uff0c\u7279\u5225\u662f\u751f\u6210\u8f03\u5c11redo\u7684nologging\u548cappend\u63d2\u5165\u3002Update\u548cDelete\u64cd\u4f5c\uff0c\u90fd\u6703\u751f\u6210Undo\u8a18\u9304\uff0c\u5728\u6211\u5011\u770b\u4f86\uff0c\u90fd\u662f\u53ef\u4ee5\u60f3\u8fa6\u6cd5\u6e1b\u5c11\u7684\u65b9\u6cd5\u3002<\/p>\n<p>\u9019\u7a2e\u65b9\u6cd5\u7684\u601d\u8def\u662f\uff1a\u5229\u7528insert\uff0c\u5c07\u539f\u4f86\u7684\u6578\u64da\u8868\u63d2\u5165\u5230\u4e00\u500b\u65b0\u5efa\u7acb\u7684\u6578\u64da\u8868\u3002\u5728insert\u904e\u7a0b\u4e2d\uff0c\u6574\u7406column\u7684\u53d6\u503c\uff0c\u8d77\u5230update\u76f8\u540c\u7684\u6548\u679c\u3002<\/p>\n<p>\u4e0b\u9762\u662f\u5be6\u9a57\u904e\u7a0b\u3002\u6211\u5011\u5148\u5275\u5efa\u6578\u64da\u8868\uff0c\u6ce8\u610f\u53ef\u4ee5\u8a2d\u7f6enologging\u5c6c\u6027\u3002<\/p>\n<p>SQL&gt; create tablet_renamenologgingas select * from t_target where1=0;<\/p>\n<p>Table created<\/p>\n<p>Executed in 0.889 seconds<\/p>\n<p>\u5728\u9019\u500b\u904e\u7a0b\u4e2d\uff0c\u6211\u5011\u5275\u5efa\u7684\u662f\u4e00\u500b\u7a7a\u8868\u3002\u4e4b\u5f8c\u5c31\u53ef\u4ee5\u63d2\u5165\u6578\u64da\uff0c\u9019\u7a2e\u65b9\u6cd5\u6bd4\u8f03\u9ebb\u7169\u7684\u5730\u65b9\uff0c\u5c31\u662f\u9700\u8981\u5728insert\u8173\u672c\u4e2d\u5217\u51fa\u6240\u6709\u7684\u6578\u64da\u5217\u3002\u7576\u7136\uff0c\u501f\u7528\u4e00\u4e9b\u5de5\u5177\u6280\u5de7\uff0c\u9019\u500b\u904e\u7a0b\u4e5f\u53ef\u4ee5\u5f88\u7c21\u55ae\u3002<\/p>\n<p>SQL&gt; insert\/*+append*\/into t_rename<\/p>\n<p>2 selectto_char(length(owner)) owner<\/p>\n<p>3 OBJECT_NAME,<\/p>\n<p>4 SUBOBJECT_NAME,<\/p>\n<p>5 OBJECT_ID,<\/p>\n<p>6 DATA_OBJECT_ID,<\/p>\n<p>7 OBJECT_TYPE,<\/p>\n<p>8 CREATED,<\/p>\n<p>9 LAST_DDL_TIME,<\/p>\n<p>10 TIMESTAMP,<\/p>\n<p>11 STATUS,<\/p>\n<p>12 TEMPORARY,<\/p>\n<p>13 GENERATED,<\/p>\n<p>14 SECONDARY,<\/p>\n<p>15 NAMESPACE,<\/p>\n<p>16 EDITION_NAME from t_target;<\/p>\n<p>9318016 rows inserted<\/p>\n<p>Executed in300.333seconds<\/p>\n<p>\u4f7f\u7528append\u64cd\u4f5c\uff0c\u53ef\u4ee5\u6e1b\u5c11redo log\u7684\u751f\u6210\u3002\u5f9e\u7d50\u679c\u770b\uff0c\u4e00\u5171\u57f7\u884c\u4e86300s\u5de6\u53f3\uff0c\u6548\u7387\u61c9\u8a72\u662f\u6bd4\u8f03\u597d\u7684\u3002<\/p>\n<p>\u4e4b\u5f8c\uff0c\u63d0\u4ea4\u4e8b\u52d9\u3002\u5c07\u539f\u4f86\u7684\u6578\u64da\u8868\u522a\u9664\uff0c\u5c07\u65b0\u6578\u64da\u8868rename\u6210\u539f\u6709\u6578\u64da\u8868\u540d\u7a31\u3002<\/p>\n<p>Executed in 0.031 seconds<\/p>\n<p>SQL&gt; drop table t_target purge;<\/p>\n<p>Table dropped<\/p>\n<p>Executed in 1.467 seconds<\/p>\n<p>SQL&gt; rename t_rename to t_target;<\/p>\n<p>Table renamed<\/p>\n<p>Executed in 0.499 seconds<\/p>\n<p>SQL&gt; select count(*) from t_target;<\/p>\n<p>COUNT(*)<\/p>\n<p>9318016<\/p>\n<p>Executed in 14.336 seconds<\/p>\n<p>\u6700\u5f8c\uff0c\u53ef\u4ee5\u5c07nologging\u5c6c\u6027\u4fee\u6539\u56de\u4f86\uff0c\u5c07\u6578\u64da\u8868\u7d04\u675f\u6dfb\u52a0\u4e0a\u3002<\/p>\n<p>SQL&gt; alter table t_target logging;<\/p>\n<p>Table altered<\/p>\n<p>Executed in 0.015 seconds<\/p>\n<p>\u9019\u7a2e\u65b9\u6cd5\u7684\u597d\u8655\u5728\u65bc\u6548\u7387\uff0c\u5728\u6578\u64da\u91cf\u7dad\u6301\u4e2d\u9ad8\u7684\u60c5\u6cc1\u4e0b\uff0c\u9019\u7a2e\u65b9\u6cd5\u901f\u5ea6\u662f\u6bd4\u8f03\u5438\u5f15\u4eba\u7684\u3002\u4f46\u662f\uff0c\u9019\u7a2e\u65b9\u5f0f\u4e5f\u8981\u6d88\u8017\u66f4\u591a\u7684\u5b58\u5132\u7a7a\u9593\u3002\u5728\u5b58\u5132\u7a7a\u9593\u5141\u8a31\u7684\u60c5\u6cc1\u4e0b\uff0c\u53ef\u4ee5\u7528\u9019\u7a2e\u65b9\u6cd5\u3002<\/p>\n<p>\u5982\u679c\u6578\u64da\u91cf\u66f4\u5927\uff0c\u9054\u5230\u6d77\u91cf\u7684\u7a0b\u5ea6\uff0c\u6bd4\u5982\u5e7e\u5341G\u7684\u6578\u64da\u8868\uff0c\u9019\u7a2e\u65b9\u6cd5\u5c31\u503c\u5f97\u8003\u91cf\u4e00\u4e0b\u4e86\u3002\u9700\u8981\u7d50\u5408\u786c\u9ad4\u74b0\u5883\u548c\u904b\u884c\u74b0\u5883\u5b8c\u6210\u3002\u53e6\u5916\uff0c\u9019\u7a2e\u65b9\u6cd5\u6d89\u53ca\u5230\u6578\u64da\u8868\u7684\u5275\u5efa\u7b49\u904b\u7dad\u5de5\u4f5c\u7279\u6027\uff0c\u6545\u4e0d\u9069\u5408\u5728\u61c9\u7528\u7a0b\u5f0f\u4e2d\u4f7f\u7528\uff0c\u9069\u5408\u5728\u904b\u7dad\u4eba\u54e1\u904e\u7a0b\u4e2d\u4f7f\u7528\u3002<\/p>\n<p>\u9084\u6709\uff0c\u5c31\u662f\u9019\u7a2e\u65b9\u6cd5\u7684\u5be6\u969b\u5c0d\u5099\u4efd\u7684\u5f71\u97ff\u3002\u7531\u65bc\u6211\u5011\u4f7f\u7528\u4e86nologging+append\u9078\u9805\uff0c\u751f\u6210\u7684redo log\u6578\u91cf\u662f\u4e0d\u8db3\u4ee5\u9032\u884c\u9084\u539f\u7684\uff0c\u6240\u4ee5\u5982\u679c\u8981\u5be6\u73fe\u5b8c\u5168\u6062\u5fa9\u7684\u8a71\uff0c\u8cc7\u6599\u5eab\u5be6\u969b\u4e0a\u662f\u5931\u53bb\u4e86\u9023\u7e8c\u9084\u539f\u7684\u4f9d\u64da\u3002\u56e0\u6b64\uff0c\u5982\u679c\u771f\u6b63\u4f7f\u7528\u4e86\u9019\u500b\u65b9\u6cd5\u5728\u751f\u7522\u74b0\u5883\u4e0b\uff0c\u4e4b\u5f8c\u9700\u8981\u9032\u884c\u8cc7\u6599\u5eab\u5168\u5099\u4efd\u64cd\u4f5c\u3002<\/p>\n<p>\u5982\u679c\u8cc7\u6599\u5eab\u7248\u672c\u70ba11.2\u4ee5\u4e0a\uff0c\u6211\u5011\u53ef\u4ee5\u4f7f\u7528Oracle\u7684\u4e00\u500b\u65b0\u7279\u6027dbms_parallel_execute\u5305\uff0c\u9032\u884c\u6578\u64da\u8868\u4e26\u884c\u66f4\u65b0\u3002\u8a73\u898b\u4e0b\u9762\u4ecb\u7d39\u3002<\/p>\n<p>5\u3001\u65b9\u6cd53\uff1adbms_paralle_execute\u4e26\u884c\u5305\u4f7f\u7528<\/p>\n<p>\u5176\u4ed6\u512a\u5316\u624b\u6bb5\u90fd\u7528\u4e0a\u7684\u6642\u5019\uff0c\u4e26\u884c\u662f\u53ef\u4ee5\u5617\u8a66\u7684\u65b9\u6cd5\u3002\u4e26\u884cparallel\u5c31\u662f\u5229\u7528\u591a\u500bprocess\u540c\u6642\u9032\u884c\u8655\u7406\uff0c\u5f9e\u800c\u63d0\u9ad8\u8655\u7406\u6548\u7387\u7684\u65b9\u6cd5\u3002Parallel\u7684\u4f7f\u7528\u6709\u4e00\u4e9b\u524d\u63d0\uff0c\u4e5f\u6709\u4e00\u4e9b\u4e0d\u826f\u53cd\u61c9\u3002\u4e26\u884c\u7684\u524d\u63d0\u662f\u786c\u9ad4\u652f\u6301\uff0c\u4e26\u884c\u6280\u8853\u672c\u8eab\u8981\u6d88\u8017\u5f88\u591a\u7684\u8cc7\u6e90\uff0c\u76f8\u7576\u65bc\u662f\u5c07\u4f3a\u670d\u5668\u8cc7\u6e90\u300c\u69a8\u4e7e\u300d\u4f86\u63d0\u901f\u3002\u5728\u898f\u5283\u4e26\u884c\u7b56\u7565\u7684\u6642\u5019\uff0c\u9996\u5148\u8981\u770b\u786c\u9ad4\u8cc7\u6e90\u662f\u4e0d\u662f\u652f\u6301\uff0c\u55ae\u6838CPU\u60c5\u6cc1\u4e0b\uff0c\u4e5f\u5c31\u4e0d\u9700\u8981\u4f7f\u7528\u9019\u500b\u6280\u8853\u4e86\u3002<\/p>\n<p>\u4f7f\u7528\u4e26\u884c\u4e4b\u5f8c\uff0c\u5fc5\u7136\u5c0d\u5176\u4ed6\u6b63\u5728\u904b\u884c\u7a0b\u5e8f\u3001\u4f5c\u696d\u6709\u5f71\u97ff\u3002\u6240\u4ee5\uff0c\u7b46\u8005\u7684\u7d93\u9a57\u662f\uff1a\u4e00\u822c\u61c9\u7528\u4e0d\u8981\u8003\u616e\u4e26\u884c\u7684\u4e8b\u60c5\uff0c\u5982\u679c\u767c\u73fe\u7279\u5b9a\u5834\u666f\u5b58\u5728\u4e26\u884c\u7684\u9700\u8981\uff0c\u53ef\u4ee5\u806f\u7e6bDBA\u6216\u8005\u904b\u7dad\u4eba\u54e1\u78ba\u5b9a\u53ef\u63a7\u7684\u6280\u8853\u65b9\u6848\u3002<\/p>\n<p>\u572811.2\u4e4b\u524d\uff0c\u4f7f\u7528\u4e26\u884c\u7a0d\u5fae\u8907\u96dc\u4e00\u4e9b\uff0c\u5f88\u591a\u670b\u53cb\u5728\u4f7f\u7528\u7684\u6642\u5019\u7d93\u5e38\u662f\u300c\u6709\u540d\u7121\u5be6\u300d\uff0c\u770b\u4f3c\u8a2d\u7f6e\u4e86\u4e26\u884c\uff0c\u4f46\u662f\u5be6\u969b\u9084\u662f\u55ae\u9032\u7a0b\u904b\u884c\u300211.2\u4e4b\u5f8c\uff0cOracle\u63d0\u4f9b\u4e86\u65b0\u7684\u4e26\u884c\u64cd\u4f5c\u63a5\u53e3dbms_parallel_execute\uff0c\u9019\u8b93\u4e26\u884c\u66f4\u52a0\u7c21\u55ae\u3002<\/p>\n<p>\u8aaa\u660e\uff1a\u672c\u7bc7\u4e0d\u662f\u5c08\u9580\u4ecb\u7d39dbms_parallel_execute\u63a5\u53e3\uff0c\u53ea\u4f5c\u70ba\u4ecb\u7d39\u3002\u8a73\u7d30\u5167\u5bb9\u53c3\u898b\u7b46\u8005\u5c08\u9580\u4ecb\u7d39\u9019\u500b\u63a5\u53e3\u7684\u6587\u7ae0\u3002<\/p>\n<p>dbms_parallel_execute\u5de5\u4f5c\u63a1\u7528\u4f5c\u696dtask\u65b9\u5f0f\uff0c\u5f8c\u53f0\u57f7\u884c\u3002\u9996\u5148\u662f\u6309\u7167\u7279\u5b9a\u7684\u539f\u5247\u9032\u884c\u6578\u64da\u5206\u5272\uff0c\u5c07\u5de5\u4f5c\u6578\u64da\u96c6\u5408\u5206\u5272\u70ba\u82e5\u5e72chunk\u3002\u4e4b\u5f8c\u555f\u52d5\u591a\u500b\u5f8c\u53f0job\u9032\u884c\u5de5\u4f5c\u3002\u5728\u5283\u5206\u5de5\u4f5c\u96c6\u5408\u7684\u554f\u984c\u4e0a\uff0cOracle\u63d0\u4f9b\u4e86\u4e09\u7a2e\u65b9\u6cd5\uff0crowid\u3001column_value\u548cSQL\uff0c\u5206\u5225\u6309\u7167rowid\u3001\u5217\u503c\u548c\u7279\u5b9aSQL\u8a9e\u53e5\u9032\u884c\u5206\u5272\u3002<\/p>\n<p>\u6ce8\u610f\uff1a\u4f7f\u7528dbms_parallel_execute\u63a5\u53e3\u5305\u6709\u4e00\u500b\u524d\u63d0\uff0c\u5c31\u662fjob_queue_process\u53c3\u6578\u5fc5\u9808\u8a2d\u7f6e\u975e\u7a7a\u3002\u5982\u679c\u70ba0\uff0c\u5247\u6211\u5011\u7684\u9032\u7a0b\u57f7\u884c\u4e4b\u5f8c\u88ab\u963b\u585e\u639b\u8d77\u3002<\/p>\n<p>\u6062\u8907\u6578\u64da\u74b0\u5883\u3002<\/p>\n<p>SQL&gt; create table t_targettablespace users as select * from t where 1=0;<\/p>\n<p>Table created<\/p>\n<p>Executed in 0.078 seconds<\/p>\n<p>Executed in 64.974 seconds<\/p>\n<p>Executed in 0.109 seconds<\/p>\n<p>\u53c3\u6578\u74b0\u5883\u3002<\/p>\n<p>SQL&gt; show parameter job_queue<\/p>\n<p>NAME TYPE VALUE<\/p>\n<p>job_queue_processes integer 1000<\/p>\n<p>\u5728\u9019\u500b\u4efb\u52d9\u4e2d\uff0c\u6211\u5011\u9078\u64c7\u4f7f\u7528create_chunks_by_rowid\u65b9\u6cd5\u3002\u9019\u7a2e\u65b9\u6cd5\u901a\u7528\u578b\u5f37\uff0c\u57f7\u884c\u8a08\u5283\u7a69\u5b9a\u6027\u597d\u3002<\/p>\n<p>SQL&gt; set serveroutput on;<\/p>\n<p>SQL&gt; declare<\/p>\n<p>2 vc_sqlvarchar2(1000);<\/p>\n<p>3 n_try number;<\/p>\n<p>4 n_status number;<\/p>\n<p>5 begin<\/p>\n<p>6 &#8211;create a task<\/p>\n<p>7 dbms_parallel_execute.create_task(task_name =&gt; &#8216;Huge_Update&#8217;);<\/p>\n<p>8<\/p>\n<p>9 &#8211;By Rowid<\/p>\n<p>10 dbms_parallel_execute.create_chunks_by_rowid(task_name =&gt; &#8216;Huge_Update&#8217;,<\/p>\n<p>11 table_owner =&gt; &#8216;SYS&#8217;,table_name =&gt; &#8216;T_TARGET&#8217;,by_row =&gt;true,chunk_size =&gt; 10000);<\/p>\n<p>12<\/p>\n<p>13 vc_sql := &#8216;update \/*+rowid(dda)*\/t_target set owner=to_char(length(owner)) where rowid between :start_id and :end_id&#8217;;<\/p>\n<p>14<\/p>\n<p>15 dbms_parallel_execute.run_task(task_name =&gt; &#8216;Huge_Update&#8217;,sql_stmt =&gt;vc_sql,language_flag =&gt;dbms_sql.native,parallel_level =&gt; 3);<\/p>\n<p>16 &#8211;\u9632\u6b62\u5931\u6557\u5f8c\u91cd\u555f<\/p>\n<p>17 n_try := 0;<\/p>\n<p>18 n_status := dbms_parallel_execute.task_status(&#8216;Huge_Update&#8217;);<\/p>\n<p>19 while (n_try&lt;2 and (n_status != dbms_parallel_execute.FINISHED)) loop<\/p>\n<p>20 n_try := n_try + 1;<\/p>\n<p>21 dbms_parallel_execute.resume_task(&#8216;Huge_Update&#8217;);<\/p>\n<p>22<\/p>\n<p>23 end loop;<\/p>\n<p>24<\/p>\n<p>25 dbms_output.put_line(&#8221;||n_try);<\/p>\n<p>26 dbms_parallel_execute.drop_task(&#8216;Huge_Update&#8217;);<\/p>\n<p>27 end;<\/p>\n<p>28 \/<\/p>\n<p>0<\/p>\n<p>Executed in1177.106seconds<\/p>\n<p>\u5728\u4ee3\u78bc\u4e2d\uff0c\u9700\u8981\u6ce8\u610fstart_id\u548cend_id\u5169\u500b\u7d81\u5b9a\u8b8a\u91cf\u3002\u9019\u5169\u500b\u7bc4\u570d\u503c\u662f\u63a5\u53e3\u56fa\u5b9a\u7684\u3002\u9019\u7a2e\u65b9\u6cd5\u4f7f\u7528\u4e861177s\u4f86\u5b8c\u6210\u5de5\u4f5c\u3002<\/p>\n<p>\u5728\u57f7\u884c\u904e\u7a0b\u4e2d\uff0c\u6211\u5011\u4e5f\u6709\u5f88\u591a\u65b9\u6cd5\u4f86\u76e3\u7763\u57f7\u884c\u904e\u7a0b\u3002Oracle\u63d0\u4f9b\u4e86\u5169\u500b\u8996\u5716\uff0c\u95dc\u65bcparallel_execute\u63a5\u53e3\u7684\u3002Dba_parallel_execute_tasks\u8868\u793a\u4e86\u63d0\u4ea4\u7684\u4efb\u52d9\uff0c\u88e1\u9762\u6211\u5011\u53ef\u4ee5\u770b\u5230\u72c0\u614b\u4fe1\u606f\u3002<\/p>\n<p>SQL&gt; col task_name for a15;<\/p>\n<p>SQL&gt; select task_name, status from dba_parallel_execute_tasks;<\/p>\n<p>TASK_NAME STATUS<\/p>\n<p>Huge_Update PROCESSING<\/p>\n<p>SQL&gt; select task_name, JOB_PREFIX from dba_parallel_execute_tasks;<\/p>\n<p>TASK_NAME JOB_PREFIX<\/p>\n<p>Huge_Update TASK$_655<\/p>\n<p>\u57f7\u884c\u4e2d\uff0c\u6211\u5011\u5f9ev$session\u4e2d\u53ef\u80fd\u770b\u5230\u5f8c\u53f0\u7684\u9032\u7a0b\u6703\u8a71\u3002<\/p>\n<p>SQL&gt; select sid, serial#, status, PROGRAM, SQL_ID, event from v$session where action like &#8216;TASK$_655%&#8217;;<\/p>\n<p>SID SERIAL# STATUS PROGRAM SQL_ID EVENT<\/p>\n<p>&#8212;&#8212;&#8211;<\/p>\n<p>35 507 ACTIVE oracle@bspdev.localdomain (J003) d7xw8z3nzh5cg db file scattered read<\/p>\n<p>38 119 ACTIVE oracle@bspdev.localdomain (J001) d7xw8z3nzh5cg log buffer space<\/p>\n<p>45 6612 ACTIVE oracle@bspdev.localdomain (J000) d7xw8z3nzh5cg Data file init write<\/p>\n<p>\u53e6\u4e00\u500b\u8996\u5716\u66f4\u6709\u7528dba_parallel_execute_chunks\uff0c\u5176\u4e2d\u5305\u62ec\u4e86\u6240\u6709\u7684chunk\u5c0d\u8c61\u3002Parallel Execute\u57f7\u884c\u7684\u539f\u5247\u5c31\u662f\u6578\u64da\u7684\u5283\u5206\uff0c\u9019\u500b\u8996\u5716\u4e2d\uff0c\u53ef\u4ee5\u770b\u5230\u54ea\u4e9bchunk\u5df2\u7d93\u5b8c\u6210\uff0c\u54ea\u4e9b\u6c92\u6709\u5b8c\u6210\u3002<\/p>\n<p>SQL&gt; select status, count(*) from dba_parallel_execute_chunks group by status;<\/p>\n<p>STATUS COUNT(*)<\/p>\n<p>ASSIGNED 3<\/p>\n<p>UNASSIGNED 2315<\/p>\n<p>PROCESSED 571<\/p>\n<p>ASSIGNED\u72c0\u614b\u8868\u793a\u591a\u9032\u7a0b\u72c0\u614b\u6b63\u5728\u8655\u7406\uff0c\u6211\u5011\u8a2d\u7f6e\u4e86\u4e09\u500b\u5f8c\u53f0\u9032\u7a0b\u57f7\u884c\u3002UNASSIGNED\u8868\u793a\u6c92\u6709\u5b8c\u6210\uff0c\u6b63\u7b49\u5f85\u8655\u7406\u3002PROCESSED\u8868\u793a\u5df2\u7d93\u8655\u7406\u5b8c\u3002<\/p>\n<p>\u9019\u7a2e\u65b9\u6cd5\u61c9\u8a72\u662f\u76ee\u524d\u627e\u5230\u6bd4\u8f03\u597d\u7684\u65b9\u6cd5\u3002\u7f3a\u9ede\u5c31\u662f\u4ee3\u78bc\u91cf\u6bd4\u8f03\u5927\u3002\u512a\u9ede\u662f\u8655\u7406\u4f7f\u7528\u4e26\u884c\uff0c\u5982\u679c\u7269\u7406\u689d\u4ef6\u652f\u6301\uff0c\u57f7\u884c\u6548\u7387\u662f\u5f88\u9ad8\u7684\u3002\u800c\u4e14\uff0c\u5728\u6d77\u91cf\u6578\u64da\u8868\u7684\u60c5\u6cc1\u4e0b\uff0c\u9019\u7a2e\u7b56\u7565\u662f\u5f88\u503c\u5f97\u63a8\u85a6\u7684\u3002<\/p>\n<p>6\u3001\u7d50\u8ad6<\/p>\n<p>\u66f4\u65b0\u5927\u91cf\u7684\u6578\u64da\uff0c\u662f\u6211\u5011\u5e38\u898b\u7684\u4e00\u7a2e\u554f\u984c\u5834\u666f\u3002\u7121\u8ad6\u5c0d\u958b\u767c\u4eba\u54e1\uff0c\u9084\u662f\u904b\u7dad\u4eba\u54e1\uff0c\u90fd\u6709\u4e0d\u540c\u7684\u6311\u6230\u3002\u7b46\u8005\u672c\u7bc7\u8981\u5f37\u8abf\u7684\u662f\uff1a\u6c92\u6709\u7d55\u5c0d\u597d\u7684\u7b56\u7565\uff0c\u90fd\u662f\u91dd\u5c0d\u7279\u5225\u7684\u5834\u666f\u548c\u80cc\u666f\uff0c\u9078\u53d6\u6700\u9069\u5408\u7684\u7b56\u7565\u3002\u5f9e\u800c\u66f4\u597d\u5730\u5b8c\u6210\u4efb\u52d9\u3002\u76f2\u76ee\u7684\u57f7\u884cSQL\u8a9e\u53e5\uff0c\u662f\u4e00\u7a2e\u5178\u578b\u4e0d\u8ca0\u8cac\u4efb\u7684\u884c\u70ba\uff0c\u9700\u8981\u907f\u514d\u675c\u7d55\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>2015\/06\/03\u00a0\u4f86\u6e90\uff1aITPUB \u539f\u6587\u7db2\u5740\uff1ahttps:\/\/read01.com\/BnK7jG.html [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_jetpack_memberships_contains_paid_content":false,"footnotes":""},"categories":[4],"tags":[],"class_list":["post-188","post","type-post","status-publish","format-standard","hentry","category-02pg"],"jetpack_sharing_enabled":true,"jetpack_featured_media_url":"","_links":{"self":[{"href":"https:\/\/blog.dbtopas.com\/index.php?rest_route=\/wp\/v2\/posts\/188","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/blog.dbtopas.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/blog.dbtopas.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/blog.dbtopas.com\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/blog.dbtopas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=188"}],"version-history":[{"count":3,"href":"https:\/\/blog.dbtopas.com\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions"}],"predecessor-version":[{"id":224,"href":"https:\/\/blog.dbtopas.com\/index.php?rest_route=\/wp\/v2\/posts\/188\/revisions\/224"}],"wp:attachment":[{"href":"https:\/\/blog.dbtopas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=188"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/blog.dbtopas.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=188"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/blog.dbtopas.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=188"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}