{"id":15988,"date":"2024-07-29T14:51:52","date_gmt":"2024-07-29T11:21:52","guid":{"rendered":"https:\/\/www.itpiran.net\/blog\/?p=15988"},"modified":"2024-07-29T14:51:52","modified_gmt":"2024-07-29T11:21:52","slug":"how-to-use-stored-procedures-in-mysql","status":"publish","type":"post","link":"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/how-to-use-stored-procedures-in-mysql\/","title":{"rendered":"\u5982\u4f55\u5728 MySQL \u4e2d\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b"},"content":{"rendered":"<h2 id=\"%d9%85%d9%82%d8%af%d9%85%d9%87\">\u4ecb\u7ecd<\/h2>\n<p>\u901a\u5e38\uff0c\u5728\u4f7f\u7528\u5173\u7cfb\u6570\u636e\u5e93\u65f6\uff0c\u60a8\u4f1a\u5728\u5e94\u7528\u7a0b\u5e8f\u4ee3\u7801\u4e2d\u76f4\u63a5\u53d1\u51fa\u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00 (SQL) \u8bed\u53e5\u6765\u68c0\u7d22\u6216\u64cd\u4f5c\u6570\u636e\uff0c\u4f8b\u5982 SELECT\u3001INSERT\u3001UPDATE \u6216 DELETE\u3002\u8fd9\u4e9b\u8bed\u53e5\u76f4\u63a5\u64cd\u4f5c\u5e95\u5c42\u6570\u636e\u5e93\u8868\u3002\u5982\u679c\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u8bbf\u95ee\u540c\u4e00\u4e2a\u6570\u636e\u5e93\u65f6\u4f7f\u7528\u76f8\u540c\u7684\u8bed\u53e5\u6216\u8bed\u53e5\u7ec4\uff0c\u5219\u8fd9\u4e9b\u8bed\u53e5\u901a\u5e38\u4f1a\u5728\u5404\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u91cd\u590d\u51fa\u73b0\u3002.<\/p>\n<p>\u4e0e\u8bb8\u591a\u5176\u4ed6\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf\u4e00\u6837\uff0cMySQL \u652f\u6301\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u3002\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u5c06\u4e00\u4e2a\u6216\u591a\u4e2a SQL \u8bed\u53e5\u5206\u7ec4\uff0c\u4ee5\u4fbf\u4f7f\u7528\u901a\u7528\u540d\u79f0\u8fdb\u884c\u91cd\u7528\uff0c\u5e76\u5c06\u5e38\u89c1\u7684\u4e1a\u52a1\u903b\u8f91\u5c01\u88c5\u5728\u6570\u636e\u5e93\u5185\u90e8\u3002\u5e94\u7528\u7a0b\u5e8f\u53ef\u4ee5\u901a\u8fc7\u8bbf\u95ee\u6570\u636e\u5e93\u6765\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\uff0c\u4ece\u800c\u4ee5\u4e00\u81f4\u7684\u65b9\u5f0f\u68c0\u7d22\u6216\u64cd\u4f5c\u6570\u636e\u3002.<\/p>\n<p>\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u53ef\u91cd\u7528\u7684\u4f8b\u7a0b\u6765\u6267\u884c\u5e38\u89c1\u4efb\u52a1\uff0c\u4ee5\u4fbf\u5728\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528\uff0c\u9a8c\u8bc1\u6570\u636e\uff0c\u6216\u8005\u901a\u8fc7\u9650\u5236\u6570\u636e\u5e93\u7528\u6237\u76f4\u63a5\u8bbf\u95ee\u5e95\u5c42\u8868\u548c\u53d1\u51fa\u4efb\u610f\u67e5\u8be2\u6765\u63d0\u4f9b\u989d\u5916\u7684\u6570\u636e\u8bbf\u95ee\u5b89\u5168\u5c42\u3002.<\/p>\n<p>\u5728\u672c\u6559\u7a0b\u4e2d\uff0c\u60a8\u5c06\u5b66\u4e60\u4ec0\u4e48\u662f\u5b58\u50a8\u8fc7\u7a0b\uff0c\u4ee5\u53ca\u5982\u4f55\u521b\u5efa\u8fd4\u56de\u6570\u636e\u5e76\u4f7f\u7528\u8f93\u5165\u548c\u8f93\u51fa\u53c2\u6570\u7684\u57fa\u672c\u5b58\u50a8\u8fc7\u7a0b\u3002.<\/p>\n<h5 id=\"%d9%be%db%8c%d8%b4-%d9%86%db%8c%d8%a7%d8%b2%d9%87%d8%a7\">\u5148\u51b3\u6761\u4ef6<\/h5>\n<p>\u8981\u9075\u5faa\u672c\u6307\u5357\uff0c\u60a8\u9700\u8981\u4e00\u53f0\u8fd0\u884c\u57fa\u4e8e SQL \u7684\u5173\u7cfb\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf (RDBMS) \u7684\u8ba1\u7b97\u673a\u3002\u672c\u6307\u5357\u4e2d\u7684\u8bf4\u660e\u548c\u793a\u4f8b\u5df2\u5728\u4ee5\u4e0b\u73af\u5883\u4e2d\u9a8c\u8bc1\uff1a<\/p>\n<ul>\n<li>\u670d\u52a1\u5668\u8fd0\u884cUbuntu 20.04\uff0c\u6709\u4e00\u4e2a\u5177\u6709\u7ba1\u7406\u5458\u6743\u9650\u7684\u975eroot\u7528\u6237\uff0c\u5e76\u4e14\u914d\u7f6e\u4e86UFW\u9632\u706b\u5899\u3002<\/li>\n<li>\u670d\u52a1\u5668\u4e0a\u5df2\u5b89\u88c5\u5e76\u914d\u7f6e\u4e86 MySQL \u5b89\u5168\u63aa\u65bd\u3002<\/li>\n<li>\u6267\u884c SELECT \u67e5\u8be2\u4ece\u6570\u636e\u5e93\u4e2d\u68c0\u7d22\u6570\u636e\u7684\u57fa\u672c\u4ecb\u7ecd<\/li>\n<\/ul>\n<p><span style=\"color: #ff0000;\">\u6ce8\u610f\uff1a\u8bb8\u591a\u5173\u7cfb\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf (RDBMS) \u4f7f\u7528\u5404\u81ea\u72ec\u7279\u7684 SQL \u5b9e\u73b0\uff0c\u5b58\u50a8\u8fc7\u7a0b\u7684\u8bed\u6cd5\u5e76\u975e SQL \u5b98\u65b9\u6807\u51c6\u7684\u4e00\u90e8\u5206\u3002\u867d\u7136\u672c\u6559\u7a0b\u4e2d\u63d0\u5230\u7684\u547d\u4ee4\u53ef\u80fd\u5728\u5176\u4ed6 RDBMS \u4e2d\u4e5f\u80fd\u8fd0\u884c\uff0c\u4f46\u5b58\u50a8\u8fc7\u7a0b\u662f\u6570\u636e\u5e93\u7279\u6709\u7684\uff0c\u56e0\u6b64\u5982\u679c\u60a8\u5728 MySQL \u4ee5\u5916\u7684\u7cfb\u7edf\u4e0a\u6d4b\u8bd5\u8fd9\u4e9b\u547d\u4ee4\uff0c\u5176\u786e\u5207\u7684\u8bed\u6cd5\u6216\u8f93\u51fa\u7ed3\u679c\u53ef\u80fd\u4f1a\u6709\u6240\u4e0d\u540c\u3002.<\/span><\/p>\n<p>\u60a8\u8fd8\u9700\u8981\u4e00\u4e2a\u7a7a\u6570\u636e\u5e93\uff0c\u4ee5\u4fbf\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u521b\u5efa\u8868\u3002\u6211\u4eec\u5efa\u8bae\u60a8\u6309\u7167\u4e0b\u6587\u201c\u8fde\u63a5\u5230 MySQL \u5e76\u8bbe\u7f6e\u793a\u4f8b\u6570\u636e\u5e93\u201d\u90e8\u5206\u4e2d\u7684\u8bf4\u660e\uff0c\u4e86\u89e3\u5982\u4f55\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\u4ee5\u53ca\u521b\u5efa\u672c\u6307\u5357\u793a\u4f8b\u4e2d\u4f7f\u7528\u7684\u6d4b\u8bd5\u6570\u636e\u5e93\u3002.<\/p>\n<h2 id=\"%d8%a7%d8%aa%d8%b5%d8%a7%d9%84-%d8%a8%d9%87-mysql-%d9%88-%d8%b1%d8%a7%d9%87-%d8%a7%d9%86%d8%af%d8%a7%d8%b2%db%8c-%db%8c%da%a9-%d9%be%d8%a7%db%8c%da%af%d8%a7%d9%87-%d8%af%d8%a7%d8%af%d9%87-%d9%86%d9%85\">\u8fde\u63a5\u5230 MySQL \u5e76\u8bbe\u7f6e\u793a\u4f8b\u6570\u636e\u5e93<\/h2>\n<p>\u5728\u672c\u8282\u4e2d\uff0c\u60a8\u5c06\u8fde\u63a5\u5230 MySQL \u670d\u52a1\u5668\u5e76\u521b\u5efa\u4e00\u4e2a\u793a\u4f8b\u6570\u636e\u5e93\uff0c\u4ee5\u4fbf\u60a8\u53ef\u4ee5\u4f7f\u7528\u672c\u6307\u5357\u4e2d\u7684\u793a\u4f8b\u3002.<\/p>\n<p>\u5728\u672c\u6307\u5357\u4e2d\uff0c\u60a8\u5c06\u4f7f\u7528\u4e00\u4e2a\u865a\u6784\u7684\u6c7d\u8f66\u6536\u85cf\u3002\u60a8\u9700\u8981\u8bb0\u5f55\u60a8\u76ee\u524d\u62e5\u6709\u7684\u6c7d\u8f66\u7684\u8be6\u7ec6\u4fe1\u606f\uff0c\u5305\u62ec\u5b83\u4eec\u7684\u54c1\u724c\u3001\u578b\u53f7\u3001\u751f\u4ea7\u5e74\u4efd\u548c\u4ef7\u503c\u3002.<\/p>\n<p>\u5982\u679c\u60a8\u7684 SQL \u6570\u636e\u5e93\u7cfb\u7edf\u8fd0\u884c\u5728\u8fdc\u7a0b\u670d\u52a1\u5668\u4e0a\uff0c\u8bf7\u4ece\u672c\u5730\u8ba1\u7b97\u673a\u901a\u8fc7 SSH \u8fde\u63a5\u5230\u60a8\u7684\u670d\u52a1\u5668\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>ssh sammy@your_server_ip\r\n<\/code><\/pre>\n<\/div>\n<p>\u7136\u540e\u6253\u5f00 MySQL \u670d\u52a1\u5668\u63d0\u793a\u7b26\uff0c\u5e76\u5c06 Sami \u66ff\u6362\u4e3a\u60a8\u7684 MySQL \u7528\u6237\u540d\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>mysql -u sammy -p\r\n<\/code><\/pre>\n<\/div>\n<p>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a processes \u7684\u6570\u636e\u5e93\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>CREATE DATABASE procedures;\r\n<\/code><\/pre>\n<\/div>\n<p>\u5982\u679c\u6570\u636e\u5e93\u521b\u5efa\u6210\u529f\uff0c\u60a8\u5c06\u6536\u5230\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nQuery OK, 1 row affected (0.01 sec)<\/code><\/pre>\n<\/div>\n<p>\u8981\u9009\u62e9\u8fc7\u7a0b\u6570\u636e\u5e93\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b USE \u8bed\u53e5\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-bash\" data-lang=\"Bash\"><code>USE procedures;\r\n<\/code><\/pre>\n<\/div>\n<p>\u60a8\u5c06\u5f97\u5230\u4ee5\u4e0b\u8f93\u51fa\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nDatabase changed<\/code><\/pre>\n<\/div>\n<p>\u9009\u62e9\u6570\u636e\u5e93\u540e\uff0c\u5373\u53ef\u5728\u5176\u4e2d\u521b\u5efa\u5b9e\u4f8b\u8868\u3002\u8868 machines \u5c06\u5305\u542b\u6570\u636e\u5e93\u4e2d\u673a\u5668\u7684\u7b80\u5316\u6570\u636e\u3002\u5b83\u5305\u542b\u4ee5\u4e0b\u5217\uff1a<\/p>\n<ul>\n<li>\u54c1\u724c\uff1a\u6b64\u5217\u8868\u793a\u5176\u62e5\u6709\u7684\u6bcf\u8f86\u8f66\uff0c\u4f7f\u7528 varchar \u6570\u636e\u7c7b\u578b\u8868\u793a\uff0c\u6700\u591a 100 \u4e2a\u5b57\u7b26\u3002.<\/li>\n<li>\u578b\u53f7\uff1a\u6b64\u5217\u5305\u542b\u6c7d\u8f66\u578b\u53f7\u540d\u79f0\uff0c\u4f7f\u7528 varchar \u6570\u636e\u7c7b\u578b\u8868\u793a\uff0c\u6700\u591a 100 \u4e2a\u5b57\u7b26\u3002.<\/li>\n<li>\u5e74\u4efd\uff1a\u6b64\u5217\u5b58\u50a8\u6c7d\u8f66\u7684\u751f\u4ea7\u5e74\u4efd\uff0c\u6570\u636e\u7c7b\u578b\u4e3a int\uff0c\u7528\u4e8e\u4fdd\u5b58\u6570\u503c\u3002.<\/li>\n<li>\u503c\uff1a\u6b64\u5217\u5b58\u50a8\u6c7d\u8f66\u7684\u503c\uff0c\u4f7f\u7528\u5341\u8fdb\u5236\u6570\u636e\u7c7b\u578b\uff0c\u6700\u591a 10 \u4f4d\u6570\u5b57\uff0c\u5c0f\u6570\u70b9\u540e\u4fdd\u7559 2 \u4f4d\u3002.<\/li>\n<\/ul>\n<p>\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u521b\u5efa\u793a\u4f8b\u8868\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>CREATE TABLE cars (\r\nmake varchar(100),\r\nmodel varchar(100),\r\nyear int,\r\nvalue decimal(10, 2)\r\n);<\/code><\/pre>\n<\/div>\n<p>\u5982\u679c\u6253\u5370\u51fa\u4ee5\u4e0b\u8f93\u51fa\uff0c\u5219\u8868\u793a\u8868\u683c\u5df2\u521b\u5efa\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nQuery OK, 0 rows affected (0.00 sec)<\/code><\/pre>\n<\/div>\n<p>\u7136\u540e\uff0c\u901a\u8fc7\u6267\u884c\u4ee5\u4e0b INSERT INTO \u64cd\u4f5c\uff0c\u5c06\u793a\u4f8b\u6570\u636e\u52a0\u8f7d\u5230 Cars \u8868\u4e2d\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>INSERT INTO cars\r\nVALUES\r\n('Porsche', '911 GT3', 2020, 169700),\r\n('Porsche', 'Cayman GT4', 2018, 118000),\r\n('Porsche', 'Panamera', 2022, 113200),\r\n('Porsche', 'Macan', 2019, 27400),\r\n('Porsche', '718 Boxster', 2017, 48880),\r\n('Ferrari', '488 GTB', 2015, 254750),\r\n('Ferrari', 'F8 Tributo', 2019, 375000),\r\n('Ferrari', 'SF90 Stradale', 2020, 627000),\r\n('Ferrari', '812 Superfast', 2017, 335300),\r\n('Ferrari', 'GTC4Lusso', 2016, 268000);<\/code><\/pre>\n<\/div>\n<p>INSERT INTO \u64cd\u4f5c\u5411\u8868\u4e2d\u6dfb\u52a0\u4e86\u5341\u8f86\u793a\u4f8b\u8dd1\u8f66\uff0c\u5176\u4e2d\u4e94\u8f86\u662f\u4fdd\u65f6\u6377\uff0c\u4e94\u8f86\u662f\u6cd5\u62c9\u5229\u3002\u4ee5\u4e0b\u8f93\u51fa\u663e\u793a\u6240\u6709\u4e94\u884c\u6570\u636e\u5747\u5df2\u6dfb\u52a0\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nQuery OK, 10 rows affected (0.00 sec)\r\nRecords: 10 Duplicates: 0 Warnings: 0<\/code><\/pre>\n<\/div>\n<p>\u81f3\u6b64\uff0c\u60a8\u5c31\u53ef\u4ee5\u7ee7\u7eed\u9605\u8bfb\u672c\u6307\u5357\u7684\u5176\u4f59\u90e8\u5206\uff0c\u5f00\u59cb\u5728 SQL \u4e2d\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u4e86\u3002.<\/p>\n<h2 id=\"%d9%85%d9%82%d8%af%d9%85%d9%87-%d8%a7%db%8c-%d8%a8%d8%b1-%d8%b1%d9%88%db%8c%d9%87-%d9%87%d8%a7%db%8c-%d8%b0%d8%ae%db%8c%d8%b1%d9%87-%d8%b4%d8%af%d9%87\">\u5b58\u50a8\u8fc7\u7a0b\u7b80\u4ecb<\/h2>\n<p>\u5728 MySQL \u548c\u8bb8\u591a\u5176\u4ed6\u5173\u7cfb\u578b\u6570\u636e\u5e93\u7cfb\u7edf\u4e2d\uff0c\u5b58\u50a8\u8fc7\u7a0b\u88ab\u79f0\u4e3a\u5bf9\u8c61\uff0c\u5b83\u5305\u542b\u4e00\u6761\u6216\u591a\u6761\u6307\u4ee4\uff0c\u8fd9\u4e9b\u6307\u4ee4\u4f1a\u5728\u6570\u636e\u5e93\u8c03\u7528\u65f6\u6309\u987a\u5e8f\u6267\u884c\u3002\u6700\u7b80\u5355\u7684\u4f8b\u5b50\u662f\uff0c\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u5c06\u5e38\u7528\u8868\u8fbe\u5f0f\u5b58\u50a8\u5728\u53ef\u91cd\u7528\u7684\u4f8b\u7a0b\u4e2d\uff0c\u4f8b\u5982\u4f7f\u7528\u5e38\u7528\u7b5b\u9009\u6761\u4ef6\u4ece\u6570\u636e\u5e93\u4e2d\u68c0\u7d22\u6570\u636e\u3002\u4f8b\u5982\uff0c\u60a8\u53ef\u4ee5\u521b\u5efa\u4e00\u4e2a\u5b58\u50a8\u8fc7\u7a0b\u6765\u68c0\u7d22\u6700\u8fd1\u51e0\u4e2a\u6708\u5728\u7f51\u5e97\u4e0b\u8fc7\u5355\u7684\u5ba2\u6237\u3002\u5728\u66f4\u590d\u6742\u7684\u573a\u666f\u4e2d\uff0c\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u4ee3\u8868\u5927\u578b\u7a0b\u5e8f\uff0c\u7528\u4e8e\u63cf\u8ff0\u529f\u80fd\u5f3a\u5927\u7684\u5e94\u7528\u7a0b\u5e8f\u7684\u590d\u6742\u4e1a\u52a1\u903b\u8f91\u3002.<\/p>\n<p>\u5b58\u50a8\u8fc7\u7a0b\u4e2d\u7684\u6307\u4ee4\u96c6\u53ef\u4ee5\u5305\u542b\u5e38\u89c1\u7684 SQL \u8bed\u53e5\uff0c\u4f8b\u5982 SELECT \u6216 INSERT \u67e5\u8be2\uff0c\u7528\u4e8e\u8fd4\u56de\u6216\u64cd\u4f5c\u6570\u636e\u3002\u6b64\u5916\uff0c\u5b58\u50a8\u8fc7\u7a0b\u8fd8\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u529f\u80fd\uff1a<\/p>\n<ul>\n<li>\u53c2\u6570\u4f1a\u4f20\u9012\u7ed9\u5b58\u50a8\u8fc7\u7a0b\u6216\u4ece\u5b58\u50a8\u8fc7\u7a0b\u8fd4\u56de\u3002.<\/li>\n<li>\u5728\u8fc7\u7a0b\u4ee3\u7801\u4e2d\u76f4\u63a5\u58f0\u660e\u7528\u4e8e\u5904\u7406\u68c0\u7d22\u5230\u7684\u6570\u636e\u7684\u53d8\u91cf\u3002.<\/li>\n<li>\u6761\u4ef6\u8bed\u53e5\u5141\u8bb8\u6839\u636e\u67d0\u4e9b\u6761\u4ef6\u6267\u884c\u5b58\u50a8\u8fc7\u7a0b\u4ee3\u7801\u7684\u67d0\u4e9b\u90e8\u5206\uff0c\u4f8b\u5982 IF \u6216 CASE \u8bed\u53e5\u3002.<\/li>\n<li>WHILE\u3001LOOP \u548c REPEAT \u7b49\u5faa\u73af\u5141\u8bb8\u591a\u6b21\u6267\u884c\u4ee3\u7801\u6bb5\uff0c\u4f8b\u5982\u5bf9\u68c0\u7d22\u5230\u7684\u6570\u636e\u96c6\u4e2d\u7684\u6bcf\u4e00\u884c\u6267\u884c\u4e00\u6b21\u3002.<\/li>\n<li>\u9519\u8bef\u5904\u7406\u6307\u4ee4\uff0c\u4f8b\u5982\u5411\u6709\u6743\u8bbf\u95ee\u8be5\u8fc7\u7a0b\u7684\u6570\u636e\u5e93\u7528\u6237\u8fd4\u56de\u9519\u8bef\u6d88\u606f\u3002.<\/li>\n<li>\u8c03\u7528\u6570\u636e\u5e93\u4e2d\u7684\u5176\u4ed6\u5b58\u50a8\u8fc7\u7a0b\u3002.<\/li>\n<\/ul>\n<p><span style=\"color: #ff0000;\">\u6ce8\u610f\uff1aMySQL \u652f\u6301\u7684\u4e30\u5bcc\u8bed\u6cd5\u4f7f\u5f97\u7f16\u5199\u529f\u80fd\u5f3a\u5927\u7684\u7a0b\u5e8f\u5e76\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u89e3\u51b3\u590d\u6742\u95ee\u9898\u6210\u4e3a\u53ef\u80fd\u3002\u672c\u6307\u5357\u4ec5\u6db5\u76d6\u5b58\u50a8\u8fc7\u7a0b\u7684\u57fa\u672c\u7528\u6cd5\uff0c\u5305\u62ec\u5c06 SQL \u8bed\u53e5\u5305\u542b\u5728\u5b58\u50a8\u8fc7\u7a0b\u4f53\u4e2d\u4ee5\u53ca\u8f93\u5165\u548c\u8f93\u51fa\u53c2\u6570\u3002\u6761\u4ef6\u4ee3\u7801\u6267\u884c\u3001\u53d8\u91cf\u7684\u4f7f\u7528\u3001\u5faa\u73af\u548c\u81ea\u5b9a\u4e49\u9519\u8bef\u5904\u7406\u8d85\u51fa\u4e86\u672c\u6307\u5357\u7684\u8303\u56f4\u3002\u6211\u4eec\u5efa\u8bae\u60a8\u9605\u8bfb MySQL \u5b98\u65b9\u6587\u6863\uff0c\u4e86\u89e3\u66f4\u591a\u5173\u4e8e\u5b58\u50a8\u8fc7\u7a0b\u7684\u4fe1\u606f\u3002.<\/span><\/p>\n<p>&nbsp;<\/p>\n<p>\u5f53\u6309\u540d\u79f0\u8c03\u7528\u8be5\u8fc7\u7a0b\u65f6\uff0c\u6570\u636e\u5e93\u5f15\u64ce\u4f1a\u6309\u7167\u5b9a\u4e49\u9010\u6761\u6307\u4ee4\u6267\u884c\u5b83\u3002.<\/p>\n<p>\u6570\u636e\u5e93\u7528\u6237\u5fc5\u987b\u62e5\u6709\u6267\u884c\u6307\u5b9a\u8fc7\u7a0b\u7684\u76f8\u5e94\u6743\u9650\u3002\u6b64\u6743\u9650\u8981\u6c42\u63d0\u4f9b\u4e86\u4e00\u5c42\u5b89\u5168\u4fdd\u969c\uff0c\u65e2\u7981\u6b62\u76f4\u63a5\u8bbf\u95ee\u6570\u636e\u5e93\uff0c\u53c8\u5141\u8bb8\u7528\u6237\u8bbf\u95ee\u53ef\u4ee5\u5b89\u5168\u6267\u884c\u7684\u5355\u4e2a\u8fc7\u7a0b\u3002.<\/p>\n<p>\u5b58\u50a8\u8fc7\u7a0b\u76f4\u63a5\u5728\u6570\u636e\u5e93\u670d\u52a1\u5668\u4e0a\u8fd0\u884c\uff0c\u6240\u6709\u8ba1\u7b97\u90fd\u5728\u672c\u5730\u6267\u884c\uff0c\u5e76\u4e14\u4ec5\u5728\u5b8c\u6210\u540e\u624d\u5c06\u7ed3\u679c\u8fd4\u56de\u7ed9\u8c03\u7528\u7528\u6237\u3002.<\/p>\n<p>\u5982\u679c\u8981\u66f4\u6539\u67d0\u4e2a\u8fc7\u7a0b\u7684\u884c\u4e3a\uff0c\u53ea\u9700\u66f4\u65b0\u6570\u636e\u5e93\u4e2d\u7684\u8be5\u8fc7\u7a0b\uff0c\u4f7f\u7528\u8be5\u8fc7\u7a0b\u7684\u5e94\u7528\u7a0b\u5e8f\u5c06\u81ea\u52a8\u63a5\u6536\u65b0\u7248\u672c\u3002\u6240\u6709\u7528\u6237\u65e0\u9700\u8c03\u6574\u5e94\u7528\u7a0b\u5e8f\u5373\u53ef\u7acb\u5373\u5f00\u59cb\u4f7f\u7528\u65b0\u7684\u8fc7\u7a0b\u4ee3\u7801\u3002.<\/p>\n<p>\u4ee5\u4e0b\u662f\u7528\u4e8e\u521b\u5efa\u5b58\u50a8\u8fc7\u7a0b\u7684 SQL \u4ee3\u7801\u7684\u4e00\u822c\u7ed3\u6784\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>DELIMITER \/\/\r\nCREATE PROCEDURE procedure_name(parameter_1, parameter_2, . . ., parameter_n)\r\nBEGIN\r\ninstruction_1;\r\ninstruction_2;\r\n. . .\r\ninstruction_n;\r\nEND \/\/\r\nDELIMITER ;<\/code><\/pre>\n<\/div>\n<p>\u8fd9\u6bb5\u4ee3\u7801\u7247\u6bb5\u4e2d\u7684\u7b2c\u4e00\u4e2a\u548c\u6700\u540e\u4e00\u4e2a\u6307\u4ee4\u5206\u522b\u662f `DELIMITER \/\/` \u548c `DELIMITER ;`\u3002MySQL \u901a\u5e38\u4f7f\u7528\u5206\u53f7 (;) \u6765\u5206\u9694\u8bed\u53e5\uff0c\u5e76\u6307\u793a\u8bed\u53e5\u7684\u5f00\u59cb\u548c\u7ed3\u675f\u3002\u5982\u679c\u60a8\u5728 MySQL \u63a7\u5236\u53f0\u4e2d\u8fd0\u884c\u591a\u4e2a\u4ee5\u5206\u53f7\u5206\u9694\u7684\u547d\u4ee4\uff0c\u5b83\u4eec\u4f1a\u88ab\u89c6\u4e3a\u5355\u72ec\u7684\u547d\u4ee4\u5e76\u4f9d\u6b21\u72ec\u7acb\u6267\u884c\u3002\u4f46\u662f\uff0c\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u5305\u542b\u591a\u4e2a\u547d\u4ee4\uff0c\u8fd9\u4e9b\u547d\u4ee4\u5728\u88ab\u8c03\u7528\u65f6\u4f1a\u6309\u987a\u5e8f\u6267\u884c\u3002\u5f53\u60a8\u5c1d\u8bd5\u6307\u793a MySQL \u521b\u5efa\u4e00\u4e2a\u65b0\u8fc7\u7a0b\u65f6\uff0c\u5c31\u4f1a\u51fa\u73b0\u95ee\u9898\u3002\u6570\u636e\u5e93\u5f15\u64ce\u4f1a\u5728\u5b58\u50a8\u8fc7\u7a0b\u7684\u4e3b\u4f53\u4e2d\u9047\u5230\u5206\u53f7\uff0c\u5e76\u8ba4\u4e3a\u5e94\u8be5\u505c\u6b62\u6267\u884c\u8be5\u547d\u4ee4\u3002\u5728\u8fd9\u79cd\u60c5\u51b5\u4e0b\uff0c\u6709\u95ee\u9898\u7684\u547d\u4ee4\u662f\u6574\u4e2a\u8fc7\u7a0b\u521b\u5efa\u4ee3\u7801\uff0c\u800c\u4e0d\u662f\u8fc7\u7a0b\u672c\u8eab\u4e2d\u7684\u5355\u4e2a\u6307\u4ee4\uff0c\u56e0\u6b64 MySQL \u4f1a\u8bef\u89e3\u60a8\u7684\u610f\u56fe\u3002.<\/p>\n<p>\u4e3a\u4e86\u514b\u670d\u8fd9\u4e2a\u9650\u5236\uff0c\u53ef\u4ee5\u4f7f\u7528 DELIMITER \u8bed\u53e5\u5728 CREATE PROCEDURE \u8c03\u7528\u671f\u95f4\u4e34\u65f6\u5c06\u5206\u9694\u7b26\u4ece ; \u66f4\u6539\u4e3a \/\/\u3002\u8fd9\u6837\uff0c\u5b58\u50a8\u8fc7\u7a0b\u4e3b\u4f53\u5185\u7684\u6240\u6709\u5206\u53f7\u90fd\u4f1a\u539f\u5c01\u4e0d\u52a8\u5730\u53d1\u9001\u5230\u670d\u52a1\u5668\u3002\u6574\u4e2a\u8fc7\u7a0b\u5b8c\u6210\u540e\uff0c\u5206\u9694\u7b26\u4f1a\u901a\u8fc7\u6700\u540e\u4e00\u4e2a DELIMITER ; \u8bed\u53e5\u6062\u590d\u4e3a ;\u3002.<\/p>\n<p>\u521b\u5efa\u65b0\u5b58\u50a8\u8fc7\u7a0b\u7684\u4ee3\u7801\u6838\u5fc3\u662f CREATE PROCEDURE \u8c03\u7528\uff0c\u540e\u9762\u8ddf\u7740\u5b58\u50a8\u8fc7\u7a0b\u540d\u79f0\uff1a\u4f8b\u5982\uff0cprocedure_name\u3002\u5b58\u50a8\u8fc7\u7a0b\u540d\u79f0\u4e4b\u540e\u662f\u53ef\u9009\u7684\u53c2\u6570\u5217\u8868\uff0c\u8fd9\u4e9b\u53c2\u6570\u662f\u5b58\u50a8\u8fc7\u7a0b\u63a5\u53d7\u7684\u3002\u6700\u540e\u4e00\u90e8\u5206\u662f\u5b58\u50a8\u8fc7\u7a0b\u4e3b\u4f53\uff0c\u5305\u542b\u5728 BEGIN \u548c END \u8bed\u53e5\u4e2d\u3002\u5b58\u50a8\u8fc7\u7a0b\u4ee3\u7801\u5185\u90e8\u53ef\u4ee5\u5305\u542b SQL \u8bed\u53e5\uff0c\u4f8b\u5982 SELECT \u67e5\u8be2\uff0c\u6216\u8005\u66f4\u590d\u6742\u7684\u4ee3\u7801\u3002.<\/p>\n<p>END \u547d\u4ee4\u4ee5\u4e34\u65f6\u5206\u9694\u7b26 \/\/ \u7ed3\u5c3e\uff0c\u800c\u4e0d\u662f\u4ee5\u666e\u901a\u7684\u5206\u53f7\u7ed3\u5c3e\u3002.<\/p>\n<p>\u4e0b\u4e00\u8282\u4e2d\uff0c\u60a8\u5c06\u521b\u5efa\u4e00\u4e2a\u57fa\u672c\u7684\u65e0\u53c2\u6570\u5b58\u50a8\u8fc7\u7a0b\u6765\u5c01\u88c5\u67e5\u8be2\u3002.<\/p>\n<h2 id=\"%d8%a7%db%8c%d8%ac%d8%a7%d8%af-%db%8c%da%a9-%d8%b1%d9%88%db%8c%d9%87-%d8%b0%d8%ae%db%8c%d8%b1%d9%87-%d8%b4%d8%af%d9%87-%d8%a8%d8%af%d9%88%d9%86-%d9%be%d8%a7%d8%b1%d8%a7%d9%85%d8%aa%d8%b1\">\u521b\u5efa\u4e0d\u5e26\u53c2\u6570\u7684\u5b58\u50a8\u8fc7\u7a0b<\/h2>\n<p>\u5728\u672c\u8282\u4e2d\uff0c\u60a8\u5c06\u521b\u5efa\u7b2c\u4e00\u4e2a\u5b58\u50a8\u8fc7\u7a0b\uff0c\u5176\u4e2d\u5305\u542b\u4e00\u4e2a SQL SELECT \u8bed\u53e5\uff0c\u7528\u4e8e\u8fd4\u56de\u6309\u54c1\u724c\u548c\u4ef7\u503c\u964d\u5e8f\u6392\u5217\u7684\u8f66\u8f86\u5217\u8868\u3002.<\/p>\n<p>\u9996\u5148\u6267\u884c\u60a8\u60f3\u8981\u4f7f\u7528\u7684 SELECT \u8bed\u53e5\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>SELECT * FROM cars ORDER BY make, value DESC;\r\n<\/code><\/pre>\n<\/div>\n<p>\u6570\u636e\u5e93\u4ece Cars \u8868\u4e2d\u8fd4\u56de\u6c7d\u8f66\u5217\u8868\uff0c\u9996\u5148\u6309\u54c1\u724c\u6392\u5e8f\uff0c\u7136\u540e\u5728\u540c\u4e00\u54c1\u724c\u5185\u6309\u4ef7\u503c\u964d\u5e8f\u6392\u5217\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\n+---------+---------------+------+-----------+\r\n| make | model | year | value |\r\n+---------+---------------+------+-----------+\r\n| Ferrari | SF90 Stradale | 2020 | 627000.00 |\r\n| Ferrari | F8 Tributo | 2019 | 375000.00 |\r\n| Ferrari | 812 Superfast | 2017 | 335300.00 |\r\n| Ferrari | GTC4Lusso | 2016 | 268000.00 |\r\n| Ferrari | 488 GTB | 2015 | 254750.00 |\r\n| Porsche | 911 GT3 | 2020 | 169700.00 |\r\n| Porsche | Cayman GT4 | 2018 | 118000.00 |\r\n| Porsche | Panamera | 2022 | 113200.00 |\r\n| Porsche | 718 Boxster | 2017 | 48880.00 |\r\n| Porsche | Macan | 2019 | 27400.00 |\r\n+---------+---------------+------+-----------+\r\n10 rows in set (0.00 sec)<\/code><\/pre>\n<\/div>\n<p>\u6700\u503c\u94b1\u7684\u6cd5\u62c9\u5229\u6392\u5728\u699c\u9996\uff0c\u6700\u4e0d\u503c\u94b1\u7684\u4fdd\u65f6\u6377\u6392\u5728\u699c\u672b\u3002.<\/p>\n<p>\u5047\u8bbe\u6b64\u67e5\u8be2\u5728\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u6216\u7531\u591a\u4e2a\u7528\u6237\u91cd\u590d\u4f7f\u7528\uff0c\u5e76\u4e14\u60a8\u5e0c\u671b\u786e\u4fdd\u6bcf\u4e2a\u4eba\u90fd\u4f7f\u7528\u76f8\u540c\u7684\u65b9\u6cd5\u6765\u5bf9\u7ed3\u679c\u8fdb\u884c\u6392\u5e8f\u3002\u4e3a\u6b64\uff0c\u60a8\u9700\u8981\u521b\u5efa\u4e00\u4e2a\u5b58\u50a8\u8fc7\u7a0b\uff0c\u5c06\u8be5\u8868\u8fbe\u5f0f\u5b58\u50a8\u5728\u4e00\u4e2a\u53ef\u91cd\u7528\u7684\u547d\u540d\u8fc7\u7a0b\u4e2d\u3002.<\/p>\n<p>\u8981\u521b\u5efa\u6b64\u5b58\u50a8\u8fc7\u7a0b\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u4ee3\u7801\u7247\u6bb5\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>DELIMITER \/\/\r\nCREATE PROCEDURE get_all_cars()\r\nBEGIN\r\nSELECT * FROM cars ORDER BY make, value DESC;\r\nEND \/\/\r\nDELIMITER ;<\/code><\/pre>\n<\/div>\n<p>\u5982\u4e0a\u4e00\u8282\u6240\u8ff0\uff0c\u7b2c\u4e00\u4e2a\u548c\u6700\u540e\u4e00\u4e2a\u8bed\u53e5\uff08DELIMITER \/\/ \u548c DELIMITER \ud83d\ude09\uff09\u544a\u8bc9 MySQL \u5728\u8fc7\u7a0b\u521b\u5efa\u671f\u95f4\u5ffd\u7565\u5206\u53f7\u5b57\u7b26\u4f5c\u4e3a\u8bed\u53e5\u5206\u9694\u7b26\u3002.<\/p>\n<p>CREATE PROCEDURE SQL \u8bed\u53e5\u4e4b\u540e\u662f\u8fc7\u7a0b\u540d\u79f0 get_all_cars\uff0c\u60a8\u53ef\u4ee5\u81ea\u5b9a\u4e49\u8be5\u540d\u79f0\u4ee5\u66f4\u597d\u5730\u63cf\u8ff0\u8fc7\u7a0b\u7684\u529f\u80fd\u3002\u8fc7\u7a0b\u540d\u79f0\u4e4b\u540e\u662f\u4e00\u5bf9\u5706\u62ec\u53f7 ()\uff0c\u60a8\u53ef\u4ee5\u5728\u5176\u4e2d\u6dfb\u52a0\u53c2\u6570\u3002\u5728\u672c\u4f8b\u4e2d\uff0c\u8be5\u8fc7\u7a0b\u672a\u4f7f\u7528\u53c2\u6570\uff0c\u56e0\u6b64\u5706\u62ec\u53f7\u4e3a\u7a7a\u3002\u7136\u540e\uff0c\u5728\u5b9a\u4e49\u8fc7\u7a0b\u4ee3\u7801\u5757\u5f00\u59cb\u548c\u7ed3\u675f\u7684 BEGIN \u548c END \u8bed\u53e5\u4e4b\u95f4\uff0c\u539f\u5c01\u4e0d\u52a8\u5730\u5199\u5165\u4e4b\u524d\u4f7f\u7528\u7684 SELECT \u8bed\u53e5\u3002.<\/p>\n<p>\u6570\u636e\u5e93\u5c06\u8fd4\u56de\u6210\u529f\u6d88\u606f\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nQuery OK, 0 rows affected (0.02 sec)<\/code><\/pre>\n<\/div>\n<p>get_all_cars \u8fc7\u7a0b\u73b0\u5728\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\uff0c\u8c03\u7528\u65f6\u4f1a\u6309\u539f\u6837\u6267\u884c\u5b58\u50a8\u7684\u8bed\u53e5\u3002.<\/p>\n<p>\u8981\u6267\u884c\u5b58\u50a8\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u4f7f\u7528 CALL SQL \u547d\u4ee4\uff0c\u540e\u8ddf\u8fc7\u7a0b\u540d\u79f0\u3002\u5c1d\u8bd5\u50cf\u8fd9\u6837\u6267\u884c\u65b0\u521b\u5efa\u7684\u8fc7\u7a0b\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>CALL get_all_cars;\r\n<\/code><\/pre>\n<\/div>\n<p>\u60a8\u53ea\u9700\u8981\u5b58\u50a8\u8fc7\u7a0b\u540d\u79f0 `get_all_cars` \u5373\u53ef\u4f7f\u7528\u8be5\u5b58\u50a8\u8fc7\u7a0b\u3002\u60a8\u4e0d\u518d\u9700\u8981\u624b\u52a8\u8f93\u5165\u4e4b\u524d\u4f7f\u7528\u7684 SELECT \u8bed\u53e5\u7684\u4efb\u4f55\u90e8\u5206\u3002\u6570\u636e\u5e93\u4f1a\u50cf\u6267\u884c SELECT \u8bed\u53e5\u7684\u8f93\u51fa\u4e00\u6837\u6267\u884c\u7ed3\u679c\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\n+---------+---------------+------+-----------+\r\n| make | model | year | value |\r\n+---------+---------------+------+-----------+\r\n| Ferrari | SF90 Stradale | 2020 | 627000.00 |\r\n| Ferrari | F8 Tributo | 2019 | 375000.00 |\r\n| Ferrari | 812 Superfast | 2017 | 335300.00 |\r\n| Ferrari | GTC4Lusso | 2016 | 268000.00 |\r\n| Ferrari | 488 GTB | 2015 | 254750.00 |\r\n| Porsche | 911 GT3 | 2020 | 169700.00 |\r\n| Porsche | Cayman GT4 | 2018 | 118000.00 |\r\n| Porsche | Panamera | 2022 | 113200.00 |\r\n| Porsche | 718 Boxster | 2017 | 48880.00 |\r\n| Porsche | Macan | 2019 | 27400.00 |\r\n+---------+---------------+------+-----------+\r\n10 rows in set (0.00 sec)\r\nQuery OK, 0 rows affected (0.00 sec)<\/code><\/pre>\n<\/div>\n<p>\u60a8\u5df2\u6210\u529f\u521b\u5efa\u4e86\u4e00\u4e2a\u4e0d\u5e26\u4efb\u4f55\u53c2\u6570\u7684\u5b58\u50a8\u8fc7\u7a0b\uff0c\u8be5\u8fc7\u7a0b\u4f1a\u6309\u7279\u5b9a\u987a\u5e8f\u8fd4\u56de Cars \u8868\u4e2d\u7684\u6240\u6709\u8f66\u8f86\u3002\u60a8\u53ef\u4ee5\u5728\u591a\u4e2a\u5e94\u7528\u7a0b\u5e8f\u4e2d\u4f7f\u7528\u6b64\u65b9\u6cd5\u3002.<\/p>\n<p>\u5728\u4e0b\u4e00\u8282\u4e2d\uff0c\u60a8\u5c06\u521b\u5efa\u4e00\u4e2a\u63a5\u53d7\u53c2\u6570\u7684\u8fc7\u7a0b\uff0c\u4ee5\u4fbf\u6839\u636e\u7528\u6237\u8f93\u5165\u6539\u53d8\u8fc7\u7a0b\u7684\u884c\u4e3a\u3002.<\/p>\n<h2 id=\"%d8%a7%db%8c%d8%ac%d8%a7%d8%af-%db%8c%da%a9-%d8%b1%d9%88%db%8c%d9%87-%d8%b0%d8%ae%db%8c%d8%b1%d9%87-%d8%b4%d8%af%d9%87-%d8%a8%d8%a7-%d9%be%d8%a7%d8%b1%d8%a7%d9%85%d8%aa%d8%b1-%d9%88%d8%b1%d9%88%d8%af\">\u521b\u5efa\u5e26\u6709\u8f93\u5165\u53c2\u6570\u7684\u5b58\u50a8\u8fc7\u7a0b<\/h2>\n<p>\u5728\u672c\u8282\u4e2d\uff0c\u60a8\u53ef\u4ee5\u5411\u5b58\u50a8\u8fc7\u7a0b\u5b9a\u4e49\u6dfb\u52a0\u8f93\u5165\u53c2\u6570\uff0c\u4ee5\u4fbf\u8fd0\u884c\u8be5\u8fc7\u7a0b\u7684\u7528\u6237\u80fd\u591f\u5411\u5176\u4f20\u9012\u6570\u636e\u3002\u4f8b\u5982\uff0c\u7528\u6237\u53ef\u4ee5\u63d0\u4f9b\u67e5\u8be2\u7b5b\u9009\u6761\u4ef6\u3002.<\/p>\n<p>\u4e4b\u524d\u7684\u5b58\u50a8\u8fc7\u7a0b `get_all_cars` \u603b\u662f\u4ece `cars` \u8868\u4e2d\u68c0\u7d22\u6240\u6709\u8f66\u8f86\u3002\u73b0\u5728\u6211\u4eec\u521b\u5efa\u53e6\u4e00\u4e2a\u5b58\u50a8\u8fc7\u7a0b\uff0c\u7528\u4e8e\u67e5\u627e\u6307\u5b9a\u5e74\u4efd\u751f\u4ea7\u7684\u8f66\u8f86\u3002\u4e3a\u6b64\uff0c\u60a8\u9700\u8981\u5728\u5b58\u50a8\u8fc7\u7a0b\u5b9a\u4e49\u4e2d\u5b9a\u4e49\u4e00\u4e2a\u540d\u4e3a `get_all_cars` \u7684\u53c2\u6570\u3002.<\/p>\n<p>\u8fd0\u884c\u4ee5\u4e0b\u4ee3\u7801\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>DELIMITER \/\/\r\nCREATE PROCEDURE get_cars_by_year(\r\nIN year_filter int\r\n)\r\nBEGIN\r\nSELECT * FROM cars WHERE year = year_filter ORDER BY make, value DESC;\r\nEND \/\/\r\nDELIMITER ;<\/code><\/pre>\n<\/div>\n<p>\u4e0e\u4e0a\u4e00\u8282\u76f8\u6bd4\uff0c\u7a0b\u5e8f\u521b\u5efa\u4ee3\u7801\u6709\u51e0\u5904\u6539\u52a8\u3002.<\/p>\n<p>\u9996\u5148\uff0c\u540d\u79f0\u662f get_cars_by_year\uff0c\u5b83\u63cf\u8ff0\u4e86\u8be5\u65b9\u6cd5\uff1a\u6839\u636e\u6c7d\u8f66\u7684\u751f\u4ea7\u5e74\u4efd\u68c0\u7d22\u6c7d\u8f66\u3002.<\/p>\n<p>\u524d\u9762\u7684\u7a7a\u62ec\u53f7\u73b0\u5728\u5305\u542b\u4e00\u4e2a\u53c2\u6570\u5b9a\u4e49\uff1a`IN year_filter int`\u3002`IN` \u5173\u952e\u5b57\u544a\u8bc9\u6570\u636e\u5e93\uff0c\u8be5\u53c2\u6570\u662f\u7531\u8c03\u7528\u7528\u6237\u4f20\u9012\u7ed9\u5b58\u50a8\u8fc7\u7a0b\u7684\u3002`year_filter` \u662f\u53c2\u6570\u7684\u4efb\u610f\u540d\u79f0\uff0c\u60a8\u5c06\u5728\u5b58\u50a8\u8fc7\u7a0b\u4ee3\u7801\u4e2d\u4f7f\u7528\u5b83\u6765\u5f15\u7528\u8be5\u53c2\u6570\u3002\u6700\u540e\uff0c`int` \u662f\u6570\u636e\u7c7b\u578b\u3002\u5728\u672c\u4f8b\u4e2d\uff0c\u751f\u4ea7\u5e74\u4efd\u4ee5\u6570\u503c\u5f62\u5f0f\u8868\u793a\u3002.<\/p>\n<p>\u5728\u8fc7\u7a0b\u540d\u79f0\u4e4b\u540e\u5b9a\u4e49\u7684 year_filter \u53c2\u6570\u51fa\u73b0\u5728 SELECT \u8bed\u53e5\u7684 WHERE year = year_filter \u5b50\u53e5\u4e2d\uff0c\u5e76\u6309\u6c7d\u8f66\u7684\u751f\u4ea7\u5e74\u4efd\u7b5b\u9009\u6c7d\u8f66\u8868\u3002.<\/p>\n<p>\u6570\u636e\u5e93\u5c06\u518d\u6b21\u8fd4\u56de\u6210\u529f\u6d88\u606f\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nQuery OK, 0 rows affected (0.02 sec)<\/code><\/pre>\n<\/div>\n<p>\u5c1d\u8bd5\u50cf\u4e4b\u524d\u4e00\u6837\uff0c\u4e0d\u4f20\u9012\u4efb\u4f55\u53c2\u6570\u8fd0\u884c\u8be5\u8fc7\u7a0b\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>CALL get_cars_by_year;\r\n<\/code><\/pre>\n<\/div>\n<p>MySQL\u6570\u636e\u5e93\u8fd4\u56de\u9519\u8bef\u4fe1\u606f\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Error message\r\nERROR 1318 (42000): Incorrect number of arguments for PROCEDURE procedures.get_cars_by_year; expected 1, got 0<\/code><\/pre>\n<\/div>\n<p>\u8fd9\u6b21\uff0c\u5b58\u50a8\u8fc7\u7a0b\u9700\u8981\u4e00\u4e2a\u53c2\u6570\uff0c\u4f46\u6ca1\u6709\u63d0\u4f9b\u4efb\u4f55\u53c2\u6570\u3002\u8981\u8c03\u7528\u5e26\u53c2\u6570\u7684\u5b58\u50a8\u8fc7\u7a0b\uff0c\u53ef\u4ee5\u6309\u7167\u8fc7\u7a0b\u671f\u671b\u7684\u987a\u5e8f\uff0c\u5c06\u53c2\u6570\u503c\u653e\u5728\u62ec\u53f7\u5185\u3002\u8981\u68c0\u7d22 2017 \u5e74\u751f\u4ea7\u7684\u6c7d\u8f66\uff0c\u8bf7\u8fd0\u884c\u4ee5\u4e0b\u547d\u4ee4\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>CALL get_cars_by_year(2017);\r\n<\/code><\/pre>\n<\/div>\n<p>\u73b0\u5728\u88ab\u8c03\u7528\u7684\u8fc7\u7a0b\u80fd\u591f\u6b63\u786e\u6267\u884c\uff0c\u5e76\u8fd4\u56de\u8be5\u5e74\u4efd\u7684\u6c7d\u8f66\u5217\u8868\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\n+---------+---------------+------+-----------+\r\n| make | model | year | value |\r\n+---------+---------------+------+-----------+\r\n| Ferrari | 812 Superfast | 2017 | 335300.00 |\r\n| Porsche | 718 Boxster | 2017 | 48880.00 |\r\n+---------+---------------+------+-----------+\r\n2 rows in set (0.00 sec)\r\nQuery OK, 0 rows affected (0.00 sec)<\/code><\/pre>\n<\/div>\n<p>\u5728\u8fd9\u4e2a\u4f8b\u5b50\u4e2d\uff0c\u4f60\u5b66\u4e60\u4e86\u5982\u4f55\u5c06\u8f93\u5165\u53c2\u6570\u4f20\u9012\u7ed9\u5b58\u50a8\u8fc7\u7a0b\uff0c\u5e76\u5728\u8fc7\u7a0b\u5185\u7684\u67e5\u8be2\u4e2d\u4f7f\u7528\u8fd9\u4e9b\u53c2\u6570\u6765\u63d0\u4f9b\u7b5b\u9009\u9009\u9879\u3002.<\/p>\n<p>\u5728\u4e0b\u4e00\u8282\u4e2d\uff0c\u60a8\u5c06\u4f7f\u7528\u8f93\u51fa\u53c2\u6570\u6765\u521b\u5efa\u5728\u4e00\u6b21\u6267\u884c\u4e2d\u8fd4\u56de\u591a\u4e2a\u4e0d\u540c\u503c\u7684\u8fc7\u7a0b\u3002.<\/p>\n<h2 id=\"%d8%a7%db%8c%d8%ac%d8%a7%d8%af-%db%8c%da%a9-%d8%b1%d9%88%db%8c%d9%87-%d8%b0%d8%ae%db%8c%d8%b1%d9%87-%d8%b4%d8%af%d9%87-%d8%a8%d8%a7-%d9%be%d8%a7%d8%b1%d8%a7%d9%85%d8%aa%d8%b1%d9%87%d8%a7%db%8c-%d9%88\">\u521b\u5efa\u5e26\u6709\u8f93\u5165\u548c\u8f93\u51fa\u53c2\u6570\u7684\u5b58\u50a8\u8fc7\u7a0b<\/h2>\n<p>\u5728\u524d\u4e24\u4e2a\u793a\u4f8b\u4e2d\uff0c\u60a8\u521b\u5efa\u7684\u5b58\u50a8\u8fc7\u7a0b\u90fd\u8c03\u7528\u4e86 SELECT \u8bed\u53e5\u6765\u8fd4\u56de\u4e00\u7ec4\u7ed3\u679c\u3002\u4f46\u5728\u67d0\u4e9b\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u4e00\u4e2a\u5b58\u50a8\u8fc7\u7a0b\uff0c\u8be5\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u4e00\u6b21\u6027\u8fd4\u56de\u591a\u4e2a\u4e0d\u540c\u7684\u503c\uff0c\u800c\u4e0d\u662f\u4e3a\u67e5\u8be2\u8fd4\u56de\u5355\u4e2a\u7ed3\u679c\u96c6\u3002.<\/p>\n<p>\u5047\u8bbe\u4f60\u60f3\u521b\u5efa\u4e00\u4e2a\u7a0b\u5e8f\uff0c\u63d0\u4f9b\u6709\u5173\u7ed9\u5b9a\u5e74\u4efd\u6c7d\u8f66\u7684\u6c47\u603b\u4fe1\u606f\uff0c\u5305\u62ec\u6536\u85cf\u4e2d\u7684\u6c7d\u8f66\u6570\u91cf\u53ca\u5176\u5e02\u573a\u4ef7\u503c\uff08\u6700\u5c0f\u503c\u3001\u6700\u5927\u503c\u548c\u5e73\u5747\u503c\uff09\u3002.<\/p>\n<p>\u4e3a\u6b64\uff0c\u60a8\u53ef\u4ee5\u5728\u521b\u5efa\u65b0\u7684\u5b58\u50a8\u8fc7\u7a0b\u65f6\u4f7f\u7528 OUT \u53c2\u6570\u3002\u4e0e IN \u53c2\u6570\u7c7b\u4f3c\uff0cOUT \u53c2\u6570\u4e5f\u5177\u6709\u540d\u79f0\u548c\u6570\u636e\u7c7b\u578b\u3002\u4f46\u662f\uff0cOUT \u53c2\u6570\u4e0d\u662f\u5c06\u6570\u636e\u4f20\u9012\u7ed9\u5b58\u50a8\u8fc7\u7a0b\uff0c\u800c\u662f\u53ef\u4ee5\u4ece\u5b58\u50a8\u8fc7\u7a0b\u4e2d\u83b7\u53d6\u6570\u636e\uff0c\u5e76\u5c06\u503c\u8fd4\u56de\u7ed9\u8c03\u7528\u7528\u6237\u3002.<\/p>\n<p>\u521b\u5efa\u4e00\u4e2a\u540d\u4e3a get_car_stats_by_year \u7684\u8fc7\u7a0b\uff0c\u8be5\u8fc7\u7a0b\u4f7f\u7528\u8f93\u51fa\u53c2\u6570\u8fd4\u56de\u7ed9\u5b9a\u751f\u4ea7\u5e74\u4efd\u7684\u6c7d\u8f66\u7684\u6c47\u603b\u6570\u636e\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>DELIMITER \/\/\r\nCREATE PROCEDURE get_car_stats_by_year(\r\nIN year_filter int,\r\nOUT cars_number int,\r\nOUT min_value decimal(10, 2),\r\nOUT avg_value decimal(10, 2),\r\nOUT max_value decimal(10, 2)\r\n)\r\nBEGIN\r\nSELECT COUNT(*), MIN(value), AVG(value), MAX(value)\r\nINTO cars_number, min_value, avg_value, max_value\r\nFROM cars\r\nWHERE year = year_filter ORDER BY make, value DESC;\r\nEND \/\/\r\nDELIMITER ;<\/code><\/pre>\n<\/div>\n<p>\u8fd9\u6b21\uff0c\u9664\u4e86\u7528\u4e8e\u6309\u751f\u4ea7\u5e74\u4efd\u7b5b\u9009\u8f66\u8f86\u7684\u8f93\u5165\u53c2\u6570 year_filter \u4e4b\u5916\uff0c\u62ec\u53f7\u5185\u8fd8\u5b9a\u4e49\u4e86\u56db\u4e2a\u8f93\u51fa\u53c2\u6570\u3002cars_number \u53c2\u6570\u7684\u6570\u636e\u7c7b\u578b\u4e3a int\uff0c\u7528\u4e8e\u8fd4\u56de\u96c6\u5408\u4e2d\u7684\u8f66\u8f86\u6570\u91cf\u3002min_value\u3001avg_value \u548c max_value \u53c2\u6570\u8868\u793a\u5e02\u573a\u4ef7\u503c\uff0c\u6570\u636e\u7c7b\u578b\u4e3a decimal (10, 2)\uff08\u7c7b\u4f3c\u4e8e cars \u8868\u4e2d\u7684 value \u5217\uff09\u3002\u8fd9\u4e9b\u53c2\u6570\u7528\u4e8e\u8fd4\u56de\u96c6\u5408\u4e2d\u6700\u4fbf\u5b9c\u548c\u6700\u8d35\u7684\u8f66\u8f86\u4fe1\u606f\uff0c\u4ee5\u53ca\u6240\u6709\u5339\u914d\u8f66\u8f86\u7684\u5e73\u5747\u4ef7\u683c\u3002.<\/p>\n<p>SELECT \u8bed\u53e5\u4f7f\u7528 SQL \u6570\u5b66\u51fd\u6570\u4ece cars \u8868\u4e2d\u67e5\u627e\u56db\u4e2a\u503c\uff1aCOUNT \u51fd\u6570\u7528\u4e8e\u83b7\u53d6\u6c7d\u8f66\u603b\u6570\uff0cMIN\u3001AVG \u548c MAX \u51fd\u6570\u7528\u4e8e\u4ece value \u5217\u4e2d\u83b7\u53d6\u6700\u5c0f\u503c\u3001\u5e73\u5747\u503c\u548c\u6700\u5927\u503c\u3002.<\/p>\n<p>\u4e3a\u4e86\u544a\u8bc9\u6570\u636e\u5e93\u8be5\u67e5\u8be2\u7684\u7ed3\u679c\u5e94\u8be5\u5b58\u50a8\u5728\u5b58\u50a8\u8fc7\u7a0b\u7684\u8f93\u51fa\u53c2\u6570\u4e2d\uff0c\u5f15\u5165\u4e86\u4e00\u4e2a\u540d\u4e3a INTO \u7684\u65b0\u5173\u952e\u5b57\u3002\u5728 INTO \u5173\u952e\u5b57\u540e\u9762\uff0c\u5217\u51fa\u4e86\u4e0e\u68c0\u7d22\u5230\u7684\u6570\u636e\u76f8\u5173\u7684\u56db\u4e2a\u8fc7\u7a0b\u53c2\u6570\u7684\u540d\u79f0\u3002\u8fd9\u5c06\u4f7f MySQL \u5c06 COUNT(*) \u7684\u503c\u5b58\u50a8\u5728 cars_number \u53c2\u6570\u4e2d\uff0c\u5c06 MIN(value) \u7684\u7ed3\u679c\u5b58\u50a8\u5728 min_value \u53c2\u6570\u4e2d\uff0c\u4f9d\u6b64\u7c7b\u63a8\u3002.<\/p>\n<p>\u6570\u636e\u5e93\u786e\u8ba4\u8be5\u8fc7\u7a0b\u5df2\u6210\u529f\u521b\u5efa\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nQuery OK, 0 rows affected (0.02 sec)<\/code><\/pre>\n<\/div>\n<p>\u73b0\u5728\u8fd0\u884c\u4ee5\u4e0b\u65b0\u7a0b\u5e8f\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>CALL get_car_stats_by_year(2017, @number, @min, @avg, @max);\r\n<\/code><\/pre>\n<\/div>\n<p>\u8fd9\u56db\u4e2a\u65b0\u53c2\u6570\u4ee5 @ \u7b26\u53f7\u5f00\u5934\u3002\u5b83\u4eec\u662f MySQL \u63a7\u5236\u53f0\u4e2d\u7684\u5c40\u90e8\u53d8\u91cf\u540d\uff0c\u53ef\u7528\u4e8e\u4e34\u65f6\u5b58\u50a8\u6570\u636e\u3002\u5f53\u60a8\u5c06\u5b83\u4eec\u4f20\u9012\u7ed9\u521b\u5efa\u7684\u5b58\u50a8\u8fc7\u7a0b\u65f6\uff0c\u8be5\u8fc7\u7a0b\u4f1a\u5c06\u503c\u63d2\u5165\u5230\u8fd9\u4e9b\u53d8\u91cf\u4e2d\u3002.<\/p>\n<p>\u6570\u636e\u5e93\u5c06\u8fd4\u56de\u4ee5\u4e0b\u5185\u5bb9\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nQuery OK, 1 row affected (0.00 sec)<\/code><\/pre>\n<\/div>\n<p>\u8fd9\u4e0e\u4e4b\u524d\u7684\u884c\u4e3a\u4e0d\u540c\uff0c\u4e4b\u524d\u7684\u7ed3\u679c\u4f1a\u7acb\u5373\u663e\u793a\u5728\u5c4f\u5e55\u4e0a\u3002\u8fd9\u662f\u56e0\u4e3a\u5b58\u50a8\u8fc7\u7a0b\u7684\u7ed3\u679c\u5b58\u50a8\u5728\u8f93\u51fa\u53c2\u6570\u4e2d\uff0c\u800c\u4e0d\u662f\u4f5c\u4e3a\u67e5\u8be2\u7ed3\u679c\u8fd4\u56de\u3002\u8981\u8bbf\u95ee\u7ed3\u679c\uff0c\u60a8\u53ef\u4ee5\u76f4\u63a5\u5728 MySQL shell \u4e2d\u9009\u62e9\u5b83\u4eec\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>SELECT @number, @min, @avg, @max;\r\n<\/code><\/pre>\n<\/div>\n<p>\u901a\u8fc7\u6b64\u67e5\u8be2\uff0c\u60a8\u53ef\u4ee5\u4ece\u5c40\u90e8\u53d8\u91cf\u4e2d\u9009\u62e9\u503c\uff0c\u800c\u65e0\u9700\u518d\u6b21\u8c03\u7528\u5b58\u50a8\u8fc7\u7a0b\u3002\u5b58\u50a8\u8fc7\u7a0b\u4f1a\u5c06\u7ed3\u679c\u5b58\u50a8\u5728\u8fd9\u4e9b\u53d8\u91cf\u4e2d\uff0c\u5e76\u4e14\u6570\u636e\u5728\u60a8\u9000\u51fa shell \u4e4b\u524d\u4e00\u76f4\u53ef\u7528\u3002.<\/p>\n<p><span style=\"color: #ff0000;\">\u6ce8\u610f\uff1a\u6709\u5173\u5728 MySQL \u4e2d\u4f7f\u7528\u7528\u6237\u81ea\u5b9a\u4e49\u53d8\u91cf\u7684\u66f4\u591a\u4fe1\u606f\uff0c\u8bf7\u53c2\u9605\u6587\u6863\u4e2d\u7684\u201c\u7528\u6237\u81ea\u5b9a\u4e49\u53d8\u91cf\u201d\u90e8\u5206\u3002\u5728\u5e94\u7528\u7a0b\u5e8f\u5f00\u53d1\u4e2d\uff0c\u8bbf\u95ee\u5b58\u50a8\u8fc7\u7a0b\u8fd4\u56de\u6570\u636e\u7684\u65b9\u6cd5\u4f1a\u56e0\u7f16\u7a0b\u8bed\u8a00\u548c\u6846\u67b6\u7684\u4e0d\u540c\u800c\u6709\u6240\u5dee\u5f02\u3002\u5982\u6709\u7591\u95ee\uff0c\u8bf7\u53c2\u9605\u60a8\u6240\u9009\u8bed\u8a00\u548c\u6846\u67b6\u7684\u6587\u6863\u3002.<\/span><\/p>\n<p>\u8f93\u51fa\u7ed3\u679c\u663e\u793a\u67e5\u8be2\u53d8\u91cf\u7684\u503c\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\n+---------+----------+-----------+-----------+\r\n| @number | @min | @avg | @max |\r\n+---------+----------+-----------+-----------+\r\n| 2 | 48880.00 | 192090.00 | 335300.00 |\r\n+---------+----------+-----------+-----------+\r\n1 row in set (0.00 sec)<\/code><\/pre>\n<\/div>\n<p>\u8fd9\u4e9b\u6570\u503c\u5bf9\u5e94\u4e8e 2017 \u5e74\u751f\u4ea7\u7684\u6c7d\u8f66\u6570\u91cf\uff0c\u4ee5\u53ca\u8be5\u751f\u4ea7\u5e74\u4efd\u6c7d\u8f66\u7684\u6700\u4f4e\u3001\u5e73\u5747\u548c\u6700\u9ad8\u5e02\u573a\u4ef7\u503c\u3002.<\/p>\n<p>\u5728\u672c\u793a\u4f8b\u4e2d\uff0c\u60a8\u5b66\u4e60\u4e86\u5982\u4f55\u4f7f\u7528\u8f93\u51fa\u53c2\u6570\u4ece\u5b58\u50a8\u8fc7\u7a0b\u4e2d\u8fd4\u56de\u591a\u4e2a\u4e0d\u540c\u7684\u503c\u4ee5\u4f9b\u540e\u7eed\u4f7f\u7528\u3002\u4e0b\u4e00\u8282\u5c06\u4ecb\u7ecd\u5982\u4f55\u5220\u9664\u5df2\u521b\u5efa\u7684\u5b58\u50a8\u8fc7\u7a0b\u3002.<\/p>\n<h2 id=\"%d8%ad%d8%b0%d9%81-%d8%b1%d9%88%db%8c%d9%87-%d9%87%d8%a7%db%8c-%d8%b0%d8%ae%db%8c%d8%b1%d9%87-%d8%b4%d8%af%d9%87\">\u5220\u9664\u5b58\u50a8\u8fc7\u7a0b<\/h2>\n<p>\u5728\u672c\u8282\u4e2d\uff0c\u60a8\u5c06\u5220\u9664\u6570\u636e\u5e93\u4e2d\u7684\u5b58\u50a8\u8fc7\u7a0b\u3002.<\/p>\n<p>\u6709\u65f6\uff0c\u60a8\u521b\u5efa\u7684\u5b58\u50a8\u8fc7\u7a0b\u53ef\u80fd\u4e0d\u518d\u9700\u8981\u3002\u5728\u5176\u4ed6\u60c5\u51b5\u4e0b\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u66f4\u6539\u5b58\u50a8\u8fc7\u7a0b\u7684\u8fd0\u884c\u65b9\u5f0f\u3002MySQL \u4e0d\u5141\u8bb8\u60a8\u5728\u521b\u5efa\u5b58\u50a8\u8fc7\u7a0b\u540e\u66f4\u6539\u5176\u5b9a\u4e49\uff0c\u56e0\u6b64\u552f\u4e00\u7684\u65b9\u6cd5\u662f\u5148\u5220\u9664\u8be5\u5b58\u50a8\u8fc7\u7a0b\uff0c\u7136\u540e\u518d\u4f7f\u7528\u6240\u9700\u7684\u66f4\u6539\u91cd\u65b0\u521b\u5efa\u5b83\u3002.<\/p>\n<p>\u8ba9\u6211\u4eec\u5220\u9664\u6700\u540e\u4e00\u4e2a\u8fc7\u7a0b get_car_stats_by_year\u3002\u4e3a\u6b64\uff0c\u60a8\u53ef\u4ee5\u4f7f\u7528 DROP PROCEDURE \u8bed\u53e5\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>DROP PROCEDURE get_car_stats_by_year;\r\n<\/code><\/pre>\n<\/div>\n<p>\u6570\u636e\u5e93\u786e\u8ba4\u5df2\u6210\u529f\u5220\u9664\u8be5\u7a0b\u5e8f\uff0c\u5e76\u663e\u793a\u6210\u529f\u6d88\u606f\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Output\r\nQuery OK, 0 rows affected (0.02 sec)<\/code><\/pre>\n<\/div>\n<p>\u60a8\u53ef\u4ee5\u901a\u8fc7\u5c1d\u8bd5\u8c03\u7528\u8be5\u8fc7\u7a0b\u6765\u9a8c\u8bc1\u5b83\u662f\u5426\u5df2\u88ab\u5220\u9664\u3002\u8fd0\u884c\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-sql\" data-lang=\"SQL\"><code>CALL get_car_stats_by_year(2017, @number, @min, @avg, @max);\r\n<\/code><\/pre>\n<\/div>\n<p>\u8fd9\u6b21\uff0c\u4f60\u4f1a\u770b\u5230\u4e00\u6761\u9519\u8bef\u6d88\u606f\uff0c\u63d0\u793a\u6570\u636e\u5e93\u4e2d\u4e0d\u5b58\u5728\u8be5\u8fc7\u7a0b\uff1a<\/p>\n<div class=\"hcb_wrap\" data-no-translation=\"\" data-no-auto-translation=\"\">\n<pre class=\"prism line-numbers lang-plain\" data-lang=\"Plain Text\"><code>Error message\r\nERROR 1305 (42000): PROCEDURE procedures.get_car_stats_by_year does not exist<\/code><\/pre>\n<\/div>\n<p>\u5728\u672c\u8282\u4e2d\uff0c\u60a8\u5b66\u4e60\u4e86\u5982\u4f55\u4ece\u6570\u636e\u5e93\u4e2d\u5220\u9664\u5b58\u50a8\u8fc7\u7a0b\u3002.<\/p>\n<h2 id=\"%d9%86%d8%aa%db%8c%d8%ac%d9%87\">\u7ed3\u679c<\/h2>\n<p>\u901a\u8fc7\u672c\u6307\u5357\uff0c\u60a8\u5b66\u4e60\u4e86\u4ec0\u4e48\u662f\u5b58\u50a8\u8fc7\u7a0b\u4ee5\u53ca\u5982\u4f55\u5728 MySQL \u4e2d\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b\u6765\u5b58\u50a8\u53ef\u91cd\u7528\u7684\u8bed\u53e5\uff0c\u5e76\u5728\u4e4b\u540e\u6267\u884c\u5b83\u4eec\u3002\u60a8\u521b\u5efa\u4e86\u4e0d\u5e26\u53c2\u6570\u7684\u5b58\u50a8\u8fc7\u7a0b\uff0c\u4ee5\u53ca\u4f7f\u7528\u8f93\u5165\u548c\u8f93\u51fa\u53c2\u6570\u7684\u5b58\u50a8\u8fc7\u7a0b\uff0c\u4ece\u800c\u4f7f\u5b83\u4eec\u66f4\u52a0\u7075\u6d3b\u3002.<\/p>","protected":false},"excerpt":{"rendered":"\u5f15\u8a00 \u901a\u5e38\u60c5\u51b5\u4e0b\uff0c\u5728\u4f7f\u7528\u5173\u7cfb\u6570\u636e\u5e93\u65f6\uff0c\u4f1a\u4f7f\u7528\u7ed3\u6784\u5316\u67e5\u8be2\u8bed\u8a00 (SQL) \u67e5\u8be2\u2026\u2026","protected":false},"author":1,"featured_media":15989,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_yoast_wpseo_focuskw":"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0631\u0648\u06cc\u0647 \u0647\u0627\u06cc \u0630\u062e\u06cc\u0631\u0647 \u0634\u062f\u0647 \u062f\u0631 MySQL","_yoast_wpseo_title":"","_yoast_wpseo_metadesc":"","_yoast_wpseo_canonical":"","_yoast_wpseo_opengraph-description":"","_yoast_wpseo_opengraph-image":"","_yoast_wpseo_twitter-description":"","_yoast_wpseo_twitter-image":"","_yoast_wpseo_focuskeywords":"","_yoast_wpseo_primary_category":"193","footnotes":""},"categories":[193,349],"tags":[403,391],"class_list":{"0":"post-15988","1":"post","2":"type-post","3":"status-publish","4":"format-standard","5":"has-post-thumbnail","7":"category-tutorials","8":"category-database","9":"tag-data-base","10":"tag-mysql"},"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v27.3 - https:\/\/yoast.com\/product\/yoast-seo-wordpress\/ -->\n<title>\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0631\u0648\u06cc\u0647 \u0647\u0627\u06cc \u0630\u062e\u06cc\u0631\u0647 \u0634\u062f\u0647 \u062f\u0631 MySQL - \u0628\u0644\u0627\u06af ITPiran<\/title>\n<meta name=\"robots\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/how-to-use-stored-procedures-in-mysql\/\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0631\u0648\u06cc\u0647 \u0647\u0627\u06cc \u0630\u062e\u06cc\u0631\u0647 \u0634\u062f\u0647 \u062f\u0631 MySQL - \u0628\u0644\u0627\u06af ITPiran\" \/>\n<meta property=\"og:description\" content=\"\u0645\u0642\u062f\u0645\u0647 \u0628\u0647 \u0637\u0648\u0631 \u0645\u0639\u0645\u0648\u0644\u060c \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u06cc\u06a9 \u067e\u0627\u06cc\u06af\u0627\u0647 \u062f\u0627\u062f\u0647 \u0631\u0627\u0628\u0637\u0647\u200c\u0627\u06cc\u060c \u062f\u0631\u062e\u0648\u0627\u0633\u062a\u200c\u0647\u0627\u06cc \u0632\u0628\u0627\u0646 \u067e\u0631\u0633 \u0648 \u062c\u0648 \u0633\u0627\u062e\u062a\u0627\u0631\u06cc\u0627\u0641\u062a\u0647 (SQL)&hellip;\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/how-to-use-stored-procedures-in-mysql\/\" \/>\n<meta property=\"og:site_name\" content=\"\u0628\u0644\u0627\u06af ITPiran\" \/>\n<meta property=\"article:published_time\" content=\"2024-07-29T11:21:52+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/cdn.itpiran.net\/2024\/07\/29143001\/sql2.jpg\" \/>\n\t<meta property=\"og:image:width\" content=\"1793\" \/>\n\t<meta property=\"og:image:height\" content=\"1110\" \/>\n\t<meta property=\"og:image:type\" content=\"image\/jpeg\" \/>\n<meta name=\"author\" content=\"admin\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"admin\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"3 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\\\/\\\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/#article\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/\"},\"author\":{\"name\":\"admin\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/person\\\/04ed27b919baca468a2273f8e4318f81\"},\"headline\":\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0631\u0648\u06cc\u0647 \u0647\u0627\u06cc \u0630\u062e\u06cc\u0631\u0647 \u0634\u062f\u0647 \u062f\u0631 MySQL\",\"datePublished\":\"2024-07-29T11:21:52+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/\"},\"wordCount\":169,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/07\\\/29143001\\\/sql2.jpg\",\"keywords\":[\"data base\",\"MySQL\"],\"articleSection\":[\"\u0622\u0645\u0648\u0632\u0634\u06cc\",\"\u067e\u0627\u06cc\u06af\u0627\u0647 \u062f\u0627\u062f\u0647\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/\",\"name\":\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0631\u0648\u06cc\u0647 \u0647\u0627\u06cc \u0630\u062e\u06cc\u0631\u0647 \u0634\u062f\u0647 \u062f\u0631 MySQL - \u0628\u0644\u0627\u06af ITPiran\",\"isPartOf\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/#primaryimage\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/#primaryimage\"},\"thumbnailUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/07\\\/29143001\\\/sql2.jpg\",\"datePublished\":\"2024-07-29T11:21:52+00:00\",\"breadcrumb\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/#primaryimage\",\"url\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/07\\\/29143001\\\/sql2.jpg\",\"contentUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2024\\\/07\\\/29143001\\\/sql2.jpg\",\"width\":1793,\"height\":1110},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/tutorials\\\/how-to-use-stored-procedures-in-mysql\\\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"Home\",\"item\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u0622\u0645\u0648\u0632\u0634\u06cc\",\"item\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/category\\\/tutorials\\\/\"},{\"@type\":\"ListItem\",\"position\":3,\"name\":\"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0631\u0648\u06cc\u0647 \u0647\u0627\u06cc \u0630\u062e\u06cc\u0631\u0647 \u0634\u062f\u0647 \u062f\u0631 MySQL\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#website\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\",\"name\":\"\u0628\u0644\u0627\u06af ITPiran\",\"description\":\"\u0627\u062e\u0628\u0627\u0631 \u0648 \u0645\u0642\u0627\u0644\u0627\u062a \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\",\"publisher\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\"},\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Organization\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#organization\",\"name\":\"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\",\"alternateName\":\"ITPIran Blog\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/\",\"logo\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\",\"url\":\"https:\\\/\\\/cdn.itpiran.net\\\/2023\\\/12\\\/27150508\\\/cropped-ITPIRAN-BLOG-LOGO-2.png\",\"contentUrl\":\"https:\\\/\\\/cdn.itpiran.net\\\/2023\\\/12\\\/27150508\\\/cropped-ITPIRAN-BLOG-LOGO-2.png\",\"width\":512,\"height\":512,\"caption\":\"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646\"},\"image\":{\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/logo\\\/image\\\/\"}},{\"@type\":\"Person\",\"@id\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/#\\\/schema\\\/person\\\/04ed27b919baca468a2273f8e4318f81\",\"name\":\"admin\",\"url\":\"https:\\\/\\\/www.itpiran.net\\\/blog\\\/zh\\\/author\\\/admin\\\/\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u5982\u4f55\u5728 MySQL \u4e2d\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b - ITPiran \u535a\u5ba2","robots":{"index":"index","follow":"follow","max-snippet":"max-snippet:-1","max-image-preview":"max-image-preview:large","max-video-preview":"max-video-preview:-1"},"canonical":"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/how-to-use-stored-procedures-in-mysql\/","og_locale":"zh_CN","og_type":"article","og_title":"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0631\u0648\u06cc\u0647 \u0647\u0627\u06cc \u0630\u062e\u06cc\u0631\u0647 \u0634\u062f\u0647 \u062f\u0631 MySQL - \u0628\u0644\u0627\u06af ITPiran","og_description":"\u0645\u0642\u062f\u0645\u0647 \u0628\u0647 \u0637\u0648\u0631 \u0645\u0639\u0645\u0648\u0644\u060c \u0647\u0646\u06af\u0627\u0645 \u06a9\u0627\u0631 \u0628\u0627 \u06cc\u06a9 \u067e\u0627\u06cc\u06af\u0627\u0647 \u062f\u0627\u062f\u0647 \u0631\u0627\u0628\u0637\u0647\u200c\u0627\u06cc\u060c \u062f\u0631\u062e\u0648\u0627\u0633\u062a\u200c\u0647\u0627\u06cc \u0632\u0628\u0627\u0646 \u067e\u0631\u0633 \u0648 \u062c\u0648 \u0633\u0627\u062e\u062a\u0627\u0631\u06cc\u0627\u0641\u062a\u0647 (SQL)&hellip;","og_url":"https:\/\/www.itpiran.net\/blog\/zh\/tutorials\/how-to-use-stored-procedures-in-mysql\/","og_site_name":"\u0628\u0644\u0627\u06af ITPiran","article_published_time":"2024-07-29T11:21:52+00:00","og_image":[{"width":1793,"height":1110,"url":"https:\/\/cdn.itpiran.net\/2024\/07\/29143001\/sql2.jpg","type":"image\/jpeg"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"3 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/#article","isPartOf":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/"},"author":{"name":"admin","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/person\/04ed27b919baca468a2273f8e4318f81"},"headline":"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0631\u0648\u06cc\u0647 \u0647\u0627\u06cc \u0630\u062e\u06cc\u0631\u0647 \u0634\u062f\u0647 \u062f\u0631 MySQL","datePublished":"2024-07-29T11:21:52+00:00","mainEntityOfPage":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/"},"wordCount":169,"commentCount":0,"publisher":{"@id":"https:\/\/www.itpiran.net\/blog\/#organization"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.itpiran.net\/2024\/07\/29143001\/sql2.jpg","keywords":["data base","MySQL"],"articleSection":["\u0622\u0645\u0648\u0632\u0634\u06cc","\u067e\u0627\u06cc\u06af\u0627\u0647 \u062f\u0627\u062f\u0647"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/","url":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/","name":"\u5982\u4f55\u5728 MySQL \u4e2d\u4f7f\u7528\u5b58\u50a8\u8fc7\u7a0b - ITPiran \u535a\u5ba2","isPartOf":{"@id":"https:\/\/www.itpiran.net\/blog\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/#primaryimage"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/#primaryimage"},"thumbnailUrl":"https:\/\/cdn.itpiran.net\/2024\/07\/29143001\/sql2.jpg","datePublished":"2024-07-29T11:21:52+00:00","breadcrumb":{"@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/#primaryimage","url":"https:\/\/cdn.itpiran.net\/2024\/07\/29143001\/sql2.jpg","contentUrl":"https:\/\/cdn.itpiran.net\/2024\/07\/29143001\/sql2.jpg","width":1793,"height":1110},{"@type":"BreadcrumbList","@id":"https:\/\/www.itpiran.net\/blog\/tutorials\/how-to-use-stored-procedures-in-mysql\/#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"Home","item":"https:\/\/www.itpiran.net\/blog\/"},{"@type":"ListItem","position":2,"name":"\u0622\u0645\u0648\u0632\u0634\u06cc","item":"https:\/\/www.itpiran.net\/blog\/category\/tutorials\/"},{"@type":"ListItem","position":3,"name":"\u0646\u062d\u0648\u0647 \u0627\u0633\u062a\u0641\u0627\u062f\u0647 \u0627\u0632 \u0631\u0648\u06cc\u0647 \u0647\u0627\u06cc \u0630\u062e\u06cc\u0631\u0647 \u0634\u062f\u0647 \u062f\u0631 MySQL"}]},{"@type":"WebSite","@id":"https:\/\/www.itpiran.net\/blog\/#website","url":"https:\/\/www.itpiran.net\/blog\/","name":"ITPiran\u535a\u5ba2","description":"\u4f0a\u6717\u53ef\u6301\u7eed\u8d38\u6613\u65b0\u95fb\u548c\u6587\u7ae0","publisher":{"@id":"https:\/\/www.itpiran.net\/blog\/#organization"},"potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.itpiran.net\/blog\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":"Organization","@id":"https:\/\/www.itpiran.net\/blog\/#organization","name":"\u4f0a\u6717\u53ef\u6301\u7eed\u5546\u4e1a\u535a\u5ba2","alternateName":"ITPIran Blog","url":"https:\/\/www.itpiran.net\/blog\/","logo":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/logo\/image\/","url":"https:\/\/cdn.itpiran.net\/2023\/12\/27150508\/cropped-ITPIRAN-BLOG-LOGO-2.png","contentUrl":"https:\/\/cdn.itpiran.net\/2023\/12\/27150508\/cropped-ITPIRAN-BLOG-LOGO-2.png","width":512,"height":512,"caption":"\u0628\u0644\u0627\u06af \u062a\u062c\u0627\u0631\u062a \u067e\u0627\u06cc\u062f\u0627\u0631 \u0627\u06cc\u0631\u0627\u0646\u06cc\u0627\u0646"},"image":{"@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/logo\/image\/"}},{"@type":"Person","@id":"https:\/\/www.itpiran.net\/blog\/#\/schema\/person\/04ed27b919baca468a2273f8e4318f81","name":"\u884c\u653f","url":"https:\/\/www.itpiran.net\/blog\/zh\/author\/admin\/"}]}},"_links":{"self":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts\/15988","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/comments?post=15988"}],"version-history":[{"count":2,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts\/15988\/revisions"}],"predecessor-version":[{"id":15991,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/posts\/15988\/revisions\/15991"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/media\/15989"}],"wp:attachment":[{"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/media?parent=15988"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/categories?post=15988"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.itpiran.net\/blog\/zh\/wp-json\/wp\/v2\/tags?post=15988"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}