{"id":200047,"date":"2025-05-06T12:03:33","date_gmt":"2025-05-06T04:03:33","guid":{"rendered":"https:\/\/server.hk\/cnblog\/200047\/"},"modified":"2025-05-06T12:03:33","modified_gmt":"2025-05-06T04:03:33","slug":"mysql-proc%e8%a1%a8%e7%9a%84%e7%bb%93%e6%9e%84%e4%b8%8e%e7%94%a8%e9%80%94%e8%af%a6%e7%bb%86%e8%a7%a3%e8%af%bb","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/200047\/","title":{"rendered":"MySQL.proc\u8868\u7684\u7ed3\u6784\u4e0e\u7528\u9014\u8be6\u7ec6\u89e3\u8bfb"},"content":{"rendered":"<p><b><\/b> <\/p>\n<h1>MySQL.proc\u8868\u7684\u7ed3\u6784\u4e0e\u7528\u9014\u8be6\u7ec6\u89e3\u8bfb<\/h1>\n<p>\u5c0f\u4f19\u4f34\u4eec\u6709\u6ca1\u6709\u89c9\u5f97\u5b66\u4e60\u5f88\u6709\u610f\u601d\uff1f\u6709\u610f\u601d\u5c31\u5bf9\u4e86\uff01\u4eca\u5929\u5c31\u7ed9\u5927\u5bb6\u5e26\u6765\uff0c\u4ee5\u4e0b\u5185\u5bb9\u5c06\u4f1a\u6d89\u53ca\u5230\uff0c\u82e5\u662f\u5728\u5b66\u4e60\u4e2d\u5bf9\u5176\u4e2d\u90e8\u5206\u77e5\u8bc6\u70b9\u6709\u7591\u95ee\uff0c\u6216\u8bb8\u770b\u4e86\u672c\u6587\u5c31\u80fd\u5e2e\u5230\u4f60\uff01<\/p>\n<p>MySQL.proc\u8868\u662fMySQL\u6570\u636e\u5e93\u4e2d\u5b58\u50a8\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u4fe1\u606f\u7684\u7cfb\u7edf\u8868\uff0c\u901a\u8fc7\u6df1\u5165\u4e86\u89e3\u5176\u7ed3\u6784\u53ca\u7528\u9014\uff0c\u53ef\u4ee5\u66f4\u597d\u5730\u7406\u89e3\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u5728MySQL\u4e2d\u7684\u8fd0\u884c\u673a\u5236\uff0c\u5e76\u8fdb\u884c\u76f8\u5173\u7684\u7ba1\u7406\u548c\u4f18\u5316\u3002\u4e0b\u9762\u5c06\u8be6\u7ec6\u89e3\u6790MySQL.proc\u8868\u7684\u7ed3\u6784\u53ca\u7528\u9014\uff0c\u5e76\u63d0\u4f9b\u5177\u4f53\u7684\u4ee3\u7801\u793a\u4f8b\u3002<\/p>\n<h2>1. MySQL.proc\u8868\u7684\u7ed3\u6784<\/h2>\n<p>MySQL.proc\u8868\u662f\u4e00\u4e2a\u7cfb\u7edf\u8868\uff0c\u5b58\u50a8\u4e86\u6240\u6709\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u7684\u5b9a\u4e49\u548c\u76f8\u5173\u4fe1\u606f\u3002\u5176\u4e3b\u8981\u5305\u542b\u4ee5\u4e0b\u5b57\u6bb5\uff1a<\/p>\n<ul>\n<li>db\uff1a\u5b58\u50a8\u8fc7\u7a0b\u6216\u51fd\u6570\u6240\u5c5e\u7684\u6570\u636e\u5e93\u540d\u79f0<\/li>\n<li>name\uff1a\u5b58\u50a8\u8fc7\u7a0b\u6216\u51fd\u6570\u7684\u540d\u79f0<\/li>\n<li>type\uff1a\u5b58\u50a8\u8fc7\u7a0b\u6216\u51fd\u6570\u7684\u7c7b\u578b\uff0c\u5305\u62ecPROCEDURE\u548cFUNCTION<\/li>\n<li>specific_name\uff1a\u5b58\u50a8\u8fc7\u7a0b\u6216\u51fd\u6570\u7684\u7279\u5b9a\u540d\u79f0<\/li>\n<li>language\uff1a\u5b58\u50a8\u8fc7\u7a0b\u6216\u51fd\u6570\u4f7f\u7528\u7684\u8bed\u8a00<\/li>\n<li>sql_data_access\uff1a\u6307\u5b9a\u5b58\u50a8\u8fc7\u7a0b\u6216\u51fd\u6570\u5bf9\u8868\u3001\u89c6\u56fe\u6216\u7ed3\u679c\u96c6\u7684\u8bbf\u95ee\u7ea7\u522b<\/li>\n<li>is_deterministic\uff1a\u6307\u5b9a\u5b58\u50a8\u8fc7\u7a0b\u6216\u51fd\u6570\u662f\u5426\u662f\u786e\u5b9a\u6027\u7684<\/li>\n<li>security_type\uff1a\u6307\u5b9a\u5b58\u50a8\u8fc7\u7a0b\u6216\u51fd\u6570\u7684\u5b89\u5168\u7c7b\u578b<\/li>\n<li>param_list\uff1a\u5b58\u50a8\u8fc7\u7a0b\u6216\u51fd\u6570\u7684\u53c2\u6570\u5217\u8868<\/li>\n<li>returns\uff1a\u5b58\u50a8\u51fd\u6570\u7684\u8fd4\u56de\u503c\u7c7b\u578b<\/li>\n<li>body\uff1a\u5b58\u50a8\u8fc7\u7a0b\u6216\u51fd\u6570\u7684\u5177\u4f53\u5b9a\u4e49<\/li>\n<\/ul>\n<h2>2. MySQL.proc\u8868\u7684\u7528\u9014<\/h2>\n<ul>\n<li>\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u67e5\u627e\uff1a\u53ef\u4ee5\u901a\u8fc7\u67e5\u8be2MySQL.proc\u8868\u83b7\u5f97\u6570\u636e\u5e93\u4e2d\u6240\u6709\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u7684\u4fe1\u606f\uff0c\u4fbf\u4e8e\u7ba1\u7406\u548c\u67e5\u627e\u3002<\/li>\n<li>\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u7684\u4fee\u6539\u548c\u4f18\u5316\uff1a\u53ef\u4ee5\u901a\u8fc7\u4fee\u6539MySQL.proc\u8868\u6765\u5bf9\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u8fdb\u884c\u8c03\u4f18\u6216\u4f18\u5316\u3002<\/li>\n<li>\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u7684\u5907\u4efd\u4e0e\u6062\u590d\uff1a\u53ef\u4ee5\u901a\u8fc7\u5907\u4efdMySQL.proc\u8868\u6765\u5907\u4efd\u6240\u6709\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u7684\u4fe1\u606f\uff0c\u65b9\u4fbf\u6062\u590d\u548c\u8fc1\u79fb\u3002<\/li>\n<\/ul>\n<h2>3. \u5177\u4f53\u4ee3\u7801\u793a\u4f8b<\/h2>\n<h3>\u67e5\u8be2\u6240\u6709\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570<\/h3>\n<pre>SELECT db, name, type, specific_name, param_list\nFROM mysql.proc;<\/pre>\n<h3>\u67e5\u8be2\u6307\u5b9a\u6570\u636e\u5e93\u4e2d\u7684\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570<\/h3>\n<pre>SELECT db, name, type, specific_name, param_list\nFROM mysql.proc\nWHERE db = 'your_database_name';<\/pre>\n<h3>\u4fee\u6539\u5b58\u50a8\u8fc7\u7a0b\u6216\u51fd\u6570\u5b9a\u4e49<\/h3>\n<pre>UPDATE mysql.proc\nSET body = 'new_definition'\nWHERE db = 'your_database_name' AND name = 'your_procedure_name';<\/pre>\n<h3>\u5907\u4efd\u6240\u6709\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u4fe1\u606f<\/h3>\n<pre>CREATE TABLE proc_backup AS\nSELECT * FROM mysql.proc;<\/pre>\n<h3>\u6062\u590d\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u4fe1\u606f<\/h3>\n<pre>DROP TABLE mysql.proc;\nALTER TABLE proc_backup RENAME TO mysql.proc;<\/pre>\n<p>\u901a\u8fc7\u4ee5\u4e0a\u7684\u6df1\u5165\u89e3\u6790\u548c\u5177\u4f53\u4ee3\u7801\u793a\u4f8b\uff0c\u5e0c\u671b\u8bfb\u8005\u80fd\u66f4\u597d\u5730\u7406\u89e3MySQL.proc\u8868\u7684\u7ed3\u6784\u53ca\u7528\u9014\uff0c\u6709\u6548\u7ba1\u7406\u548c\u4f18\u5316\u5b58\u50a8\u8fc7\u7a0b\u548c\u51fd\u6570\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u300aMySQL.proc\u8868\u7684\u7ed3\u6784\u4e0e\u7528\u9014\u8be6\u7ec6\u89e3\u8bfb\u300b\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u5173\u4e8emysql,\u7ed3\u6784,proc\u7684\u8d44\u6599\u8bf7\u5173\u6ce8\u4e3b\u673a\u5b9d\u8d1d\u516c\u4f17\u53f7\uff01<\/p>\n<dl>\n<dt>\n <\/dt>\n<\/dl>\n","protected":false},"excerpt":{"rendered":"<p>MySQL.proc\u8868\u7684\u7ed3\u6784\u4e0e\u7528&#46;&#46;&#46;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-200047","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200047","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=200047"}],"version-history":[{"count":0,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/200047\/revisions"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=200047"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=200047"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=200047"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}