{"id":17630,"date":"2024-11-18T13:03:25","date_gmt":"2024-11-18T05:03:25","guid":{"rendered":"https:\/\/fwq.ai\/blog\/17630\/"},"modified":"2024-11-18T13:03:25","modified_gmt":"2024-11-18T05:03:25","slug":"oracle%e6%9f%a5%e8%af%a2%e8%a1%a8%e9%94%81%e7%8a%b6%e6%80%81%e6%96%b9%e6%b3%95%e8%af%a6%e8%a7%a3","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/17630\/","title":{"rendered":"Oracle\u67e5\u8be2\u8868\u9501\u72b6\u6001\u65b9\u6cd5\u8be6\u89e3"},"content":{"rendered":"<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/000\/465\/014\/170978256646409.jpg\" class=\"aligncenter\" title=\"Oracle\u67e5\u8be2\u8868\u9501\u72b6\u6001\u65b9\u6cd5\u8be6\u89e3\u63d2\u56fe\" alt=\"Oracle\u67e5\u8be2\u8868\u9501\u72b6\u6001\u65b9\u6cd5\u8be6\u89e3\u63d2\u56fe\" \/><\/p>\n<p><strong>Oracle\u67e5\u8be2\u8868\u9501\u72b6\u6001\u65b9\u6cd5\u8be6\u89e3<\/strong><\/p>\n<p>\u5728\u6570\u636e\u5e93\u64cd\u4f5c\u4e2d\uff0c\u8868\u9501\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u4ed6\u4f1a\u5f71\u54cd\u5230\u6570\u636e\u5e93\u7684\u6027\u80fd\u548c\u5e76\u53d1\u5ea6\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5728Oracle\u6570\u636e\u5e93\u4e2d\u67e5\u8be2\u8868\u9501\u72b6\u6001\u7684\u65b9\u6cd5\uff0c\u5e76\u7ed9\u51fa\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<h3>1. \u67e5\u8be2\u8868\u9501\u72b6\u6001\u7684\u65b9\u6cd5<\/h3>\n<p>\u5728Oracle\u6570\u636e\u5e93\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u7cfb\u7edf\u89c6\u56fe\u4e2d\u67e5\u8be2\u6765\u83b7\u53d6\u8868\u9501\u72b6\u6001\u4fe1\u606f\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u7cfb\u7edf\u89c6\u56fe\uff1a<\/p>\n<ul>\n<li> <strong>V$LOCK<\/strong>\uff1a\u663e\u793a\u6570\u636e\u5e93\u4e2d\u9ad8\u7ea7\u9501\u4fe1\u606f\u7684\u89c6\u56fe<\/li>\n<li> <strong>DBA_BLOCKERS<\/strong>\uff1a\u663e\u793a\u5f53\u524d\u7684\u4f1a\u8bddID\u548c\u9501\u5b9a\u4f1a\u8bddID<\/li>\n<li> <strong>DBA_WAITERS<\/strong>\uff1a\u663e\u793a\u5f53\u524d\u7684\u4f1a\u8bddID\u548c\u7b49\u5f85\u4f1a\u8bddID<\/li>\n<li> <strong>DBA_DML_LOCKS<\/strong>\uff1a\u663e\u793a\u5f53\u524d\u4f1a\u8bdd\u6301\u6709\u548c\u7b49\u5f85\u7684DML\u9501\u4fe1\u606f<\/li>\n<\/ul>\n<h3>2. \u5177\u4f53\u4ee3\u7801\u793a\u4f8b<\/h3>\n<h4>2.1 \u67e5\u8be2\u8868\u4e0a\u7684\u9501\u5b9a\u4f1a\u8bdd<\/h4>\n<pre>SELECT c.object_name,\n       b.sid,\n       b.serial#,\n       b.username,\n       b.status,\n       b.server,\n       l.locked_mode,\n       l.lock_type\nFROM   v$locked_object l,\n       dba_objects c,\n       v$session b\nWHERE  l.object_id = c.object_id\nAND    l.session_id = b.sid;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u53ef\u4ee5\u67e5\u8be2\u51fa\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u5404\u4e2a\u8868\u7684\u9501\u5b9a\u4f1a\u8bdd\u4fe1\u606f\uff0c\u5305\u62ec\u4f1a\u8bddID\u3001\u6301\u6709\u9501\u7684\u7528\u6237\u3001\u9501\u7c7b\u578b\u7b49\u3002<\/p>\n<h4>2.2 \u67e5\u8be2\u5f53\u524d\u4f1a\u8bdd\u7684\u7b49\u5f85\u548c\u6301\u6709\u7684\u9501\u4fe1\u606f<\/h4>\n<pre>SELECT session_id, \n       lock_type,\n       mode_held,\n       mode_requested\nFROM   dba_dml_locks\nUNION\nSELECT holding_session session_id,\n       holding_cursor_type lock_type,\n       MODE_HELD mode_held,\n       MODE_REQUESTED mode_requested\nFROM   dba_kgl_locks<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u53ef\u4ee5\u67e5\u8be2\u5f53\u524d\u4f1a\u8bdd\u6301\u6709\u548c\u7b49\u5f85\u7684\u9501\u4fe1\u606f\uff0c\u53ef\u4ee5\u5e2e\u52a9\u6211\u4eec\u66f4\u597d\u5730\u7406\u89e3\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u9501\u7684\u5177\u4f53\u60c5\u51b5\u3002<\/p>\n<h3>3. \u603b\u7ed3<\/h3>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u7684\u4ecb\u7ecd\uff0c\u6211\u4eec\u4e86\u89e3\u4e86\u5728Oracle\u6570\u636e\u5e93\u4e2d\u67e5\u8be2\u8868\u9501\u72b6\u6001\u7684\u65b9\u6cd5\uff0c\u5e76\u7ed9\u51fa\u4e86\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u3002\u5728\u5b9e\u9645\u64cd\u4f5c\u4e2d\uff0c\u901a\u8fc7\u76d1\u63a7\u8868\u9501\u72b6\u6001\uff0c\u6211\u4eec\u53ef\u4ee5\u66f4\u597d\u5730\u4f18\u5316\u6570\u636e\u5e93\u7684\u6027\u80fd\uff0c\u63d0\u9ad8\u7cfb\u7edf\u7684\u5e76\u53d1\u5904\u7406\u80fd\u529b\u3002\u5e0c\u671b\u672c\u6587\u5bf9\u60a8\u6709\u6240\u5e2e\u52a9\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662fOracle\u67e5\u8be2\u8868\u9501\u72b6\u6001\u65b9\u6cd5\u8be6\u89e3\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Oracle\u67e5\u8be2\u8868\u9501\u72b6\u6001\u65b9\u6cd5\u8be6\u89e3 \u5728\u6570\u636e\u5e93\u64cd\u4f5c\u4e2d\uff0c\u8868\u9501\u662f\u4e00\u4e2a\u975e\u5e38\u91cd\u8981\u7684\u6982\u5ff5\uff0c\u4ed6\u4f1a\u5f71\u54cd\u5230\u6570\u636e\u5e93\u7684\u6027\u80fd\u548c\u5e76\u53d1\u5ea6\u3002\u672c\u6587\u5c06\u8be6\u7ec6\u4ecb\u7ecd\u5728Oracle\u6570\u636e\u5e93\u4e2d\u67e5\u8be2\u8868\u9501\u72b6\u6001\u7684\u65b9\u6cd5\uff0c\u5e76\u7ed9\u51fa\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u3002 1. \u67e5\u8be2\u8868\u9501\u72b6\u6001\u7684\u65b9\u6cd5 \u5728Oracle\u6570\u636e\u5e93\u4e2d\uff0c\u6211\u4eec\u53ef\u4ee5\u901a\u8fc7\u5728\u7cfb\u7edf\u89c6\u56fe\u4e2d\u67e5\u8be2\u6765\u83b7\u53d6\u8868\u9501\u72b6\u6001\u4fe1\u606f\u3002\u4e0b\u9762\u662f\u4e00\u4e9b\u5e38\u7528\u7684\u7cfb\u7edf\u89c6\u56fe\uff1a V$LOCK\uff1a\u663e\u793a\u6570\u636e\u5e93\u4e2d\u9ad8\u7ea7\u9501\u4fe1\u606f\u7684\u89c6\u56fe DBA_BLOCKERS\uff1a\u663e\u793a\u5f53\u524d\u7684\u4f1a\u8bddID\u548c\u9501\u5b9a\u4f1a\u8bddID DBA_WAITERS\uff1a\u663e\u793a\u5f53\u524d\u7684\u4f1a\u8bddID\u548c\u7b49\u5f85\u4f1a\u8bddID DBA_DML_LOCKS\uff1a\u663e\u793a\u5f53\u524d\u4f1a\u8bdd\u6301\u6709\u548c\u7b49\u5f85\u7684DML\u9501\u4fe1\u606f 2. \u5177\u4f53\u4ee3\u7801\u793a\u4f8b 2.1 \u67e5\u8be2\u8868\u4e0a\u7684\u9501\u5b9a\u4f1a\u8bdd SELECT c.object_name, b.sid, b.serial#, b.username, b.status, b.server, l.locked_mode, l.lock_type FROM v$locked_object l, dba_objects c, v$session b WHERE l.object_id = c.object_id AND l.session_id = b.sid; \u767b\u5f55\u540e\u590d\u5236 \u8fd9\u6bb5\u4ee3\u7801\u53ef\u4ee5\u67e5\u8be2\u51fa\u5f53\u524d\u6570\u636e\u5e93\u4e2d\u5404\u4e2a\u8868\u7684\u9501\u5b9a\u4f1a\u8bdd\u4fe1\u606f\uff0c\u5305\u62ec\u4f1a\u8bddID\u3001\u6301\u6709\u9501\u7684\u7528\u6237\u3001\u9501\u7c7b\u578b\u7b49\u3002 2.2 \u67e5\u8be2\u5f53\u524d\u4f1a\u8bdd\u7684\u7b49\u5f85\u548c\u6301\u6709\u7684\u9501\u4fe1\u606f SELECT session_id, lock_type, mode_held, mode_requested FROM dba_dml_locks UNION SELECT holding_session session_id, holding_cursor_type lock_type, MODE_HELD [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[8],"tags":[],"class_list":["post-17630","post","type-post","status-publish","format-standard","hentry","category-os"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/17630","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=17630"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/17630\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=17630"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=17630"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=17630"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}