{"id":4459,"date":"2020-11-20T15:09:15","date_gmt":"2020-11-20T07:09:15","guid":{"rendered":"https:\/\/nj.transwarp.cn:8180\/?p=4459"},"modified":"2020-11-20T15:15:21","modified_gmt":"2020-11-20T07:15:21","slug":"%e5%a6%82%e4%bd%95%e6%9f%a5%e7%9c%8b%e5%92%8c%e7%bb%88%e6%ad%a2%e6%ad%a3%e5%9c%a8%e8%bf%90%e8%a1%8c%e7%9a%84%e5%ad%98%e5%82%a8%e8%bf%87%e7%a8%8bplsql","status":"publish","type":"post","link":"https:\/\/kbwp.transwarp.cn\/?p=4459","title":{"rendered":"\u5982\u4f55\u67e5\u770b\u548c\u7ec8\u6b62\u6b63\u5728\u8fd0\u884c\u7684\u5b58\u50a8\u8fc7\u7a0bPLSQL"},"content":{"rendered":"<h3>\u6982\u8981\u63cf\u8ff0<\/h3>\n<hr \/>\n<p>\u7531\u4e8e\u6211\u4eec\u7684PLSQL\u662f\u8fd0\u884c\u5728HiveServer\u7aef\u7684session\u4e4b\u4e2d\uff0c\u5f53\u4e00\u6761PLSQL\u8bed\u53e5\u5c1a\u672a\u7ed3\u675f\u5e76\u4e14\u4f1a\u8fd0\u884c\u5f88\u957f\u65f6\u95f4\u7684\u65f6\u5019\uff0c\u53ef\u80fd\u5ba2\u6237\u7aef\u5df2\u7ecfCtrl+C\u6740\u6389\u81ea\u5df1\u4e86\uff0c\u800cServer\u7aef\u7531\u4e8e\u8fd8\u5728\u6267\u884cPLSQL\uff0c\u65e0\u6cd5\u4fa6\u542c\u5230\u5ba2\u6237\u7aef\u6b7b\u6389\uff0c\u8fd9\u6837\u8fd9\u4e2asession\u4e2d\u7684PLSQL\u4f1a\u53d8\u6210\u7c7b\u4f3c\u50f5\u5c38\u8fdb\u7a0b\u3002\u867d\u7136\u5ba2\u6237\u7aef\u5df2\u7ecf\u51b3\u5b9a\u653e\u5f03\u8fd9\u6b21\u6267\u884c\uff0c\u4f46\u8be5PLSQL\u4f9d\u7136\u4f1a\u7ee7\u7eed\u6267\u884c\u5230\u7ed3\u675f\uff0c\u8bbe\u60f3\u5176\u4e2d\u5982\u679c\u6709\u5927\u91cf\u7684SQL\u8bed\u53e5\u6267\u884c\u6216\u8005\u5e72\u8106\u6709\u4e2a\u6b7b\u5faa\u73af\uff0c\u4f1a\u8017\u8d39\u5927\u91cf\u7684Server\u7aef\u8d44\u6e90\u3002<\/p>\n<h3>\u8be6\u7ec6\u8bf4\u660e<\/h3>\n<hr \/>\n<h4>1. \u6267\u884c\u6d4b\u8bd5plsql\u5757<\/h4>\n<pre><code class=\"language-sql\">--\u7ed3\u5408\u7761\u7720\u51fd\u6570\u548cfor\u5faa\u73af\u6784\u9020\u4e00\u4e2a\u6267\u884c\u65f6\u95f4\u7a0d\u957f\u7684plsql\nBEGIN\n    FOR i IN 1..10 LOOP\n        put_line(i||' '||to_char(sysdate,'yyyy-MM-dd HH:mm:ss'))\n        dbms_lock.sleep(10)\n    END loop\nEND<\/code><\/pre>\n<h4>2. \u67e5\u770b\u6b63\u5728\u8fd0\u884c\u7684PLSQL<\/h4>\n<p>\u8fd9\u6761\u547d\u4ee4\u4f1a\u663e\u793asession id\u548cPLSQL\u8bed\u53e5\uff0c\u4f7f\u7528\u8005\u9700\u8981\u4ece\u4e2d\u627e\u5230\u81ea\u5df1\u60f3\u8981\u7ec8\u6b62\u7684PLSQL\u7684session id\uff1b<\/p>\n<pre><code class=\"language-sql\">> PS PLSQL;\n\nf87ef49d-5d4d-437e-a066-de2b58799239 : BEGIN\n    FOR i IN 1..10 LOOP\n        put_line(i||' '||to_char(sysdate,'yyyy-MM-dd HH:mm:ss'))\n        dbms_lock.sleep(10)\n    END loop\nEND<\/code><\/pre>\n<p><em>\u7b2c\u4e00\u884c\u7684f87ef49d-5d4d-437e-a066-de2b58799239\uff0c\u5c31\u662f\\&lt;SESSION_ID><\/em><\/p>\n<h4>3. \u7ec8\u6b62\u6b63\u5728\u8fd0\u884c\u7684\u67d0\u6761PLSQL<\/h4>\n<p>\u8fd9\u6761\u547d\u4ee4\u4f1a\u53d1\u9001\u4e00\u4e2a\u7ec8\u6b62\u4fe1\u53f7\u7ed9\u8be5session id\u4e2d\u7684PLSQL\u8fdb\u7a0b\uff0c\u5f85\u8be5\u8fdb\u7a0b\u4e0b\u4e00\u6b21\u81ea\u68c0\u4e4b\u65f6\uff0c\u53d1\u73b0\u6709\u7ec8\u6b62\u4fe1\u53f7\uff0c\u5219\u4f1a\u7ed3\u675f\u81ea\u5df1\uff1b<\/p>\n<pre><code class=\"language-sql\">-- KILL PLSQL <SESSION_ID>;\n> kill PLSQL f87ef49d-5d4d-437e-a066-de2b58799239;<\/code><\/pre>\n<p>\u5bf9\u5e94\u7684plsql\u8bed\u53e5\u4f1a\u629b\u51fa\u5f02\u5e38\uff0c<font color=red>EXECUTION FAILED: Task EXEC PLSQL error HiveException: [Error 40000] PLSQL process being killed.<\/font><\/p>\n<p><img decoding=\"async\" src=\"\/wp-content\/uploads\/2020\/11\/image-1605855903969.png\" style=\"zoom:80%\" \/><\/p>\n<hr \/>\n<p>\u81ea\u68c0\u662f\u501f\u9274\u4e86\u64cd\u4f5c\u7cfb\u7edf\u4e2d\u8fdb\u7a0b\u8c03\u5ea6\u7684\u601d\u60f3\u3002\u81ea\u68c0\u7684\u7c92\u5ea6\u4e3a\u4e00\u6761PLSQL\u8bed\u53e5\uff0c\u4e5f\u5c31\u662f\u8bf4\u6bcf\u6267\u884c\u4e00\u6761PLSQL\u8bed\u53e5\u4f1a\u81ea\u68c0\u4e00\u6b21\uff08\u4e5f\u5c31\u662f\u88abOS\u8c03\u5ea6\u4e00\u6b21\uff09\u3002\u6240\u4ee5\u5982\u679c\u6709\u4e00\u6761SQL\u8bed\u53e5\u6267\u884c\u65f6\u95f4\u7279\u522b\u957f\uff0c\u90a3\u4e48KILL\u8be5\u8fdb\u7a0b\u540e\u5e76\u4e0d\u4f1a\u9a6c\u4e0a\u751f\u6548\uff0c\u9700\u8981\u7b49\u5230\u8be5SQL\u8bed\u53e5\u6267\u884c\u5b8c\u6bd5\u624d\u4f1a\u53d1\u751f\u81ea\u68c0\u5e76\u7ec8\u6b62\u3002\u8fd9\u79cd\u60c5\u51b5\u5982\u679c\u786e\u5b9a\u8981\u7ec8\u6b62\u8be5\u8fdb\u7a0b\uff0c\u53ef\u5230inceptor\u76844040\u9875\u9762\u53bbkill\u6389\u5f53\u524d\u7684SQL\uff0c\u8fd9\u6837\u5916\u5c42PLSQL\u5c31\u4f1a\u7acb\u5373\u7ec8\u6b62\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6982\u8981\u63cf\u8ff0 \u7531\u4e8e\u6211\u4eec\u7684PLSQL\u662f\u8fd0\u884c\u5728HiveServer\u7aef\u7684session\u4e4b\u4e2d\uff0c\u5f53\u4e00\u6761PLSQL\u8bed\u53e5\u5c1a\u672a\u7ed3\u675f ..<\/p>\n<div class=\"clear-fix\"><\/div>\n<p><a href=\"https:\/\/kbwp.transwarp.cn\/?p=4459\" title=\"read more...\">Read more<\/a><\/p>\n","protected":false},"author":14,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[40],"tags":[],"class_list":["post-4459","post","type-post","status-publish","format-standard","hentry","category-sql_issue"],"acf":[],"_links":{"self":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/4459","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/users\/14"}],"replies":[{"embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=4459"}],"version-history":[{"count":2,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/4459\/revisions"}],"predecessor-version":[{"id":4570,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=\/wp\/v2\/posts\/4459\/revisions\/4570"}],"wp:attachment":[{"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=4459"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=4459"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/kbwp.transwarp.cn\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=4459"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}