{"id":34353,"date":"2025-04-29T10:38:05","date_gmt":"2025-04-29T02:38:05","guid":{"rendered":"https:\/\/www.wsisp.com\/helps\/34353.html"},"modified":"2025-04-29T10:38:05","modified_gmt":"2025-04-29T02:38:05","slug":"mysql%e4%b9%8b%e5%ad%98%e5%82%a8%e8%bf%87%e7%a8%8b%ef%bc%88%e4%b8%8b%ef%bc%89","status":"publish","type":"post","link":"https:\/\/www.wsisp.com\/helps\/34353.html","title":{"rendered":"Mysql\u4e4b\u5b58\u50a8\u8fc7\u7a0b\uff08\u4e0b\uff09"},"content":{"rendered":"<p style=\"text-align:center\">&#x1f3dd;\ufe0f\u4e13\u680f&#xff1a;Mysql_\u732b\u54aa-9527\u7684\u535a\u5ba2-CSDN\u535a\u5ba2 &#x1f305;\u4e3b\u9875&#xff1a;\u732b\u54aa-9527-CSDN\u535a\u5ba2\u00a0<\/p>\n<p style=\"text-align:center\">\u201c\u6b32\u7a77\u5343\u91cc\u76ee&#xff0c;\u66f4\u4e0a\u4e00\u5c42\u697c\u3002\u4f1a\u5f53\u51cc\u7edd\u9876&#xff0c;\u4e00\u89c8\u4f17\u5c71\u5c0f\u3002\u201d<\/p>\n<p id=\"main-toc\">\u76ee\u5f55<\/p>\n<p id=\"4.%20%E5%AD%98%E5%82%A8%E8%BF%87%E7%A8%8B-toc\" style=\"margin-left:80px\">4. \u5b58\u50a8\u8fc7\u7a0b<\/p>\n<p id=\"4.1%20IF%20%E5%88%A4%E6%96%AD-toc\" style=\"margin-left:120px\">4.1 IF \u5224\u65ad<\/p>\n<p id=\"4.2%20%E5%AD%98%E5%82%A8%E8%BF%87%E7%A8%8B%E5%8F%82%E6%95%B0-toc\" style=\"margin-left:120px\">4.2 \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570<\/p>\n<p id=\"4.2.1%20IN%20%E5%8F%82%E6%95%B0%E4%BD%BF%E7%94%A8-toc\" style=\"margin-left:160px\">4.2.1 IN \u53c2\u6570\u4f7f\u7528<\/p>\n<p id=\"4.2.2%20OUT%20%E5%8F%82%E6%95%B0%E4%BD%BF%E7%94%A8-toc\" style=\"margin-left:160px\">4.2.2 OUT \u53c2\u6570\u4f7f\u7528<\/p>\n<p id=\"4.2.3%20INOUT%20%E5%8F%82%E6%95%B0%E4%BD%BF%E7%94%A8-toc\" style=\"margin-left:160px\">4.2.3 INOUT \u53c2\u6570\u4f7f\u7528<\/p>\n<p id=\"4.3%20CASE%20%E8%AF%AD%E5%8F%A5-toc\" style=\"margin-left:120px\">4.3 CASE \u8bed\u53e5<\/p>\n<p id=\"4.4%20WHILE%20%E5%BE%AA%E7%8E%AF-toc\" style=\"margin-left:120px\">4.4 WHILE \u5faa\u73af<\/p>\n<p id=\"4.5%20REPEAT%20%E5%BE%AA%E7%8E%AF-toc\" style=\"margin-left:120px\">4.5 REPEAT \u5faa\u73af<\/p>\n<p id=\"4.6%20LOOP%20%E5%BE%AA%E7%8E%AF-toc\" style=\"margin-left:120px\">4.6 LOOP \u5faa\u73af<\/p>\n<p id=\"5.%E6%B8%B8%E6%A0%87-toc\" style=\"margin-left:80px\">5.\u6e38\u6807<\/p>\n<p id=\"5.1%C2%A0%C2%A0%E5%A3%B0%E6%98%8E%E6%B8%B8%E6%A0%87-toc\" style=\"margin-left:120px\">5.1\u00a0\u00a0\u58f0\u660e\u6e38\u6807<\/p>\n<p id=\"5.2%C2%A0%E6%89%93%E5%BC%80%E6%B8%B8%E6%A0%87-toc\" style=\"margin-left:120px\">5.2\u00a0\u6253\u5f00\u6e38\u6807<\/p>\n<p id=\"5.3%20%E5%8F%96%E5%87%BA%E6%95%B0%E6%8D%AE-toc\" style=\"margin-left:120px\">5.3 \u53d6\u51fa\u6570\u636e<\/p>\n<p id=\"5.4Handler%20(%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86%E5%99%A8)-toc\" style=\"margin-left:120px\">5.4Handler (\u5f02\u5e38\u5904\u7406\u5668)<\/p>\n<p id=\"5.4%C2%A0%E5%85%B3%E9%97%AD%E6%B8%B8%E6%A0%87-toc\" style=\"margin-left:120px\">5.4\u00a0\u5173\u95ed\u6e38\u6807<\/p>\n<p id=\"5.5%C2%A0%E6%B8%B8%E6%A0%87%E7%9A%84%E5%AE%8C%E6%95%B4%E7%A4%BA%E4%BE%8B-toc\" style=\"margin-left:120px\">5.5\u00a0\u6e38\u6807\u7684\u5b8c\u6574\u793a\u4f8b<\/p>\n<p id=\"6.%20%E8%A7%A6%E5%8F%91%E5%99%A8-toc\" style=\"margin-left:80px\">6. \u89e6\u53d1\u5668<\/p>\n<p id=\"6.1%20%E5%88%9B%E5%BB%BA%E8%A7%A6%E5%8F%91%E5%99%A8-toc\" style=\"margin-left:120px\">6.1 \u521b\u5efa\u89e6\u53d1\u5668<\/p>\n<p id=\"4.%20%E6%9F%A5%E7%9C%8B%E3%80%81%E5%88%A0%E9%99%A4%E8%A7%A6%E5%8F%91%E5%99%A8-toc\" style=\"margin-left:120px\">6.2. \u67e5\u770b\u3001\u5220\u9664\u89e6\u53d1\u5668<\/p>\n<p id=\"5.%20%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9%E4%B8%8E%E5%9D%91-toc\" style=\"margin-left:120px\">6.3. \u6ce8\u610f\u4e8b\u9879\u4e0e\u5751<\/p>\n<hr id=\"hr-toc\" \/>\n<h4 id=\"4.%20%E5%AD%98%E5%82%A8%E8%BF%87%E7%A8%8B\">4. \u5b58\u50a8\u8fc7\u7a0b<\/h4>\n<p>\u5b58\u50a8\u8fc7\u7a0b\u662f\u7531\u4e00\u7ec4 SQL \u8bed\u53e5\u6784\u6210\u7684\u6570\u636e\u5e93\u5bf9\u8c61&#xff0c;\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u88ab\u5b58\u50a8\u5728\u6570\u636e\u5e93\u4e2d\u5e76\u5728\u9700\u8981\u65f6\u6267\u884c\u3002\u5b83\u652f\u6301\u63a7\u5236\u6d41\u7ed3\u6784&#xff08;\u5982 IF \u8bed\u53e5\u3001CASE \u8bed\u53e5\u3001\u5faa\u73af\u7b49&#xff09;&#xff0c;\u80fd\u591f\u5c01\u88c5\u548c\u91cd\u7528\u6570\u636e\u5e93\u64cd\u4f5c&#xff0c;\u63d0\u5347\u4ee3\u7801\u7684\u6a21\u5757\u5316\u548c\u53ef\u7ef4\u62a4\u6027\u3002<\/p>\n<h5 id=\"4.1%20IF%20%E5%88%A4%E6%96%AD\">4.1 IF \u5224\u65ad<\/h5>\n<p>IF \u8bed\u53e5\u662f MySQL \u5b58\u50a8\u8fc7\u7a0b\u4e2d\u7684\u4e00\u79cd\u5e38\u89c1\u63a7\u5236\u6d41\u7ed3\u6784&#xff0c;\u7528\u4e8e\u6839\u636e\u7279\u5b9a\u6761\u4ef6\u6267\u884c\u4e0d\u540c\u7684 SQL \u8bed\u53e5\u3002\u5b83\u53ef\u4ee5\u5355\u72ec\u4f7f\u7528&#xff0c;\u4e5f\u53ef\u4ee5\u4e0e ELSE \u548c ELSEIF \u914d\u5408\u4f7f\u7528&#xff0c;\u4ece\u800c\u5f62\u6210\u591a\u5206\u652f\u7684\u6761\u4ef6\u5224\u65ad\u7ed3\u6784\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p>IF condition THEN<br \/>\n    &#8212; \u6267\u884c\u7684 SQL \u8bed\u53e5<br \/>\nELSEIF condition THEN<br \/>\n    &#8212; \u6267\u884c\u7684 SQL \u8bed\u53e5<br \/>\nELSE<br \/>\n    &#8212; \u6267\u884c\u7684 SQL \u8bed\u53e5<br \/>\nEND IF;<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>DELIMITER $$<\/p>\n<p>CREATE PROCEDURE CheckScore()<br \/>\nBEGIN<br \/>\n   DECLARE score INT DEFAULT 58;<br \/>\n   DECLARE result VARCHAR(10);<\/p>\n<p>   IF score &gt;&#061; 80 THEN<br \/>\n        SET result :&#061; &#039;\u4f18\u79c0&#039;;<br \/>\n   ELSEIF score &gt;&#061; 60 THEN<br \/>\n        SET result :&#061; &#039;\u53ca\u683c&#039;;<br \/>\n   ELSE<br \/>\n        SET result :&#061; &#039;\u4e0d\u53ca\u683c&#039;;<br \/>\n   END IF;<\/p>\n<p>   SELECT result;<br \/>\nEND$$<\/p>\n<p>DELIMITER ;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"183\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250429023803-68103b8b757c7.png\" width=\"1055\" \/><\/p>\n<h5 id=\"4.2%20%E5%AD%98%E5%82%A8%E8%BF%87%E7%A8%8B%E5%8F%82%E6%95%B0\">4.2 \u5b58\u50a8\u8fc7\u7a0b\u53c2\u6570<\/h5>\n<p>\u5b58\u50a8\u8fc7\u7a0b\u53ef\u4ee5\u63a5\u53d7\u4e09\u79cd\u7c7b\u578b\u7684\u53c2\u6570&#xff1a;IN\u3001OUT \u548c INOUT\u3002\u6bcf\u79cd\u7c7b\u578b\u7684\u53c2\u6570\u6709\u4e0d\u540c\u7684\u4f5c\u7528&#xff0c;\u5206\u522b\u7528\u4e8e\u6570\u636e\u7684\u8f93\u5165\u3001\u8f93\u51fa\u6216\u540c\u65f6\u8f93\u5165\u8f93\u51fa\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p>CREATE PROCEDURE \u5b58\u50a8\u8fc7\u7a0b\u540d\u79f0 (IN\/OUT\/INOUT \u53c2\u6570\u540d \u53c2\u6570\u7c7b\u578b)<br \/>\nBEGIN<br \/>\n    &#8212; SQL \u8bed\u53e5<br \/>\nEND;<\/p>\n<h6 id=\"4.2.1%20IN%20%E5%8F%82%E6%95%B0%E4%BD%BF%E7%94%A8\">4.2.1 IN \u53c2\u6570\u4f7f\u7528<\/h6>\n<p>IN \u53c2\u6570\u7528\u4e8e\u5411\u5b58\u50a8\u8fc7\u7a0b\u4f20\u9012\u8f93\u5165\u503c&#xff0c;\u5b58\u50a8\u8fc7\u7a0b\u5185\u90e8\u53ef\u4ee5\u4f7f\u7528\u8fd9\u4e9b\u503c\u8fdb\u884c\u8ba1\u7b97\u6216\u67e5\u8be2\u64cd\u4f5c\u3002<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>DELIMITER $$<\/p>\n<p>CREATE PROCEDURE CheckScoreIN(IN score INT)<br \/>\nBEGIN<br \/>\n   DECLARE result VARCHAR(10);<\/p>\n<p>   IF score &gt;&#061; 80 THEN<br \/>\n        SET result :&#061; &#039;\u4f18\u79c0&#039;;<br \/>\n   ELSEIF score &gt;&#061; 60 THEN<br \/>\n        SET result :&#061; &#039;\u53ca\u683c&#039;;<br \/>\n   ELSE<br \/>\n        SET result :&#061; &#039;\u4e0d\u53ca\u683c&#039;;<br \/>\n   END IF;<\/p>\n<p>   SELECT result;<br \/>\nEND$$<\/p>\n<p>DELIMITER ;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"185\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250429023803-68103b8baf148.png\" width=\"1046\" \/><\/p>\n<h6 id=\"4.2.2%20OUT%20%E5%8F%82%E6%95%B0%E4%BD%BF%E7%94%A8\">4.2.2 OUT \u53c2\u6570\u4f7f\u7528<\/h6>\n<p>OUT \u53c2\u6570\u7528\u4e8e\u5b58\u50a8\u8fc7\u7a0b\u8fd4\u56de\u503c\u3002\u6267\u884c\u5b58\u50a8\u8fc7\u7a0b\u65f6&#xff0c;\u8fd4\u56de\u7ed3\u679c\u5c06\u901a\u8fc7 OUT \u53c2\u6570\u4f20\u9012\u7ed9\u8c03\u7528\u8005\u3002<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>DELIMITER $$<\/p>\n<p>CREATE PROCEDURE CheckScoreOUT(IN score INT, OUT result VARCHAR(20))<br \/>\nBEGIN<br \/>\n   IF score &gt;&#061; 80 THEN<br \/>\n        SET result :&#061; &#039;\u4f18\u79c0&#039;;<br \/>\n   ELSEIF score &gt;&#061; 60 THEN<br \/>\n        SET result :&#061; &#039;\u53ca\u683c&#039;;<br \/>\n   ELSE<br \/>\n        SET result :&#061; &#039;\u4e0d\u53ca\u683c&#039;;<br \/>\n   END IF;<br \/>\nEND$$<\/p>\n<p>DELIMITER ;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"287\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250429023803-68103b8be8679.png\" width=\"1153\" \/><\/p>\n<h6 id=\"4.2.3%20INOUT%20%E5%8F%82%E6%95%B0%E4%BD%BF%E7%94%A8\">4.2.3 INOUT \u53c2\u6570\u4f7f\u7528<\/h6>\n<p>INOUT \u53c2\u6570\u65e2\u53ef\u4ee5\u4f5c\u4e3a\u8f93\u5165\u503c&#xff0c;\u4e5f\u53ef\u4ee5\u7528\u4f5c\u5b58\u50a8\u8fc7\u7a0b\u8fd4\u56de\u7684\u8f93\u51fa\u503c\u3002<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>DELIMITER $$<\/p>\n<p>CREATE PROCEDURE CheckScoreINOUT(INOUT score DOUBLE)<br \/>\nBEGIN<br \/>\n     SET score :&#061; score * 0.5;<br \/>\nEND$$<\/p>\n<p>DELIMITER ;<\/p>\n<p><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"381\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250429023804-68103b8c39619.png\" width=\"1230\" \/><\/p>\n<h5 id=\"4.3%20CASE%20%E8%AF%AD%E5%8F%A5\">4.3 CASE \u8bed\u53e5<\/h5>\n<p>CASE \u8bed\u53e5\u662f\u4e00\u79cd\u6761\u4ef6\u8868\u8fbe\u5f0f&#xff0c;\u5141\u8bb8\u6839\u636e\u4e0d\u540c\u7684\u6761\u4ef6\u9009\u62e9\u4e0d\u540c\u7684\u7ed3\u679c\u3002\u5b83\u901a\u5e38\u7528\u4e8e SELECT \u67e5\u8be2\u3001UPDATE \u8bed\u53e5\u6216\u5b58\u50a8\u8fc7\u7a0b\u4e2d\u7684\u6761\u4ef6\u5224\u65ad\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p>CASE expression<br \/>\n    WHEN value1 THEN result1<br \/>\n    WHEN value2 THEN result2<br \/>\n    WHEN value3 THEN result3<br \/>\n    ELSE default_result<br \/>\nEND<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>DELIMITER $$<\/p>\n<p>CREATE PROCEDURE CheckGrade(IN score INT, OUT grade VARCHAR(3))<br \/>\nBEGIN<br \/>\n   CASE<br \/>\n     WHEN score BETWEEN 90 AND 100 THEN SET grade :&#061; &#039;A&#039;;<br \/>\n     WHEN score BETWEEN 80 AND 89 THEN SET grade :&#061; &#039;B&#039;;<br \/>\n     WHEN score BETWEEN 60 AND 79 THEN SET grade :&#061; &#039;C&#039;;<br \/>\n     WHEN score BETWEEN 0 AND 59 THEN SET grade :&#061; &#039;D&#039;;<br \/>\n     ELSE SET grade :&#061; &#039;NO&#039;;<br \/>\n   END CASE;<br \/>\nEND$$<\/p>\n<p>DELIMITER ;<\/p>\n<h5 id=\"4.4%20WHILE%20%E5%BE%AA%E7%8E%AF\">4.4 WHILE \u5faa\u73af<\/h5>\n<p>WHILE \u5faa\u73af\u662f MySQL \u4e2d\u7684\u4e00\u79cd\u5e38\u89c1\u63a7\u5236\u7ed3\u6784&#xff0c;\u7528\u4e8e\u5728\u6307\u5b9a\u6761\u4ef6\u4e3a TRUE \u65f6\u91cd\u590d\u6267\u884c\u4e00\u7ec4 SQL \u8bed\u53e5&#xff0c;\u76f4\u5230\u6761\u4ef6\u4e0d\u518d\u6ee1\u8db3\u4e3a\u6b62\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p>WHILE condition DO<br \/>\n    &#8212; \u6267\u884c\u7684 SQL \u8bed\u53e5<br \/>\nEND WHILE;<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>DELIMITER $$<\/p>\n<p>CREATE PROCEDURE SumNumbers(IN n INT)<br \/>\nBEGIN<br \/>\n    DECLARE a INT DEFAULT 0;<br \/>\n    WHILE n &gt;&#061; 0 DO<br \/>\n        SET a :&#061; a &#043; n;<br \/>\n        SET n :&#061; n &#8211; 1;<br \/>\n    END WHILE;<br \/>\n    SELECT a;<br \/>\nEND$$<\/p>\n<p>DELIMITER ;<\/p>\n<h5 id=\"4.5%20REPEAT%20%E5%BE%AA%E7%8E%AF\">4.5 REPEAT \u5faa\u73af<\/h5>\n<p>REPEAT \u5faa\u73af\u4e0e WHILE \u5faa\u73af\u7c7b\u4f3c&#xff0c;\u4e0d\u540c\u4e4b\u5904\u5728\u4e8e\u5b83\u5728\u6bcf\u6b21\u6267\u884c\u4ee3\u7801\u5757\u540e\u624d\u68c0\u67e5\u6761\u4ef6&#xff0c;\u76f4\u5230\u6ee1\u8db3\u9000\u51fa\u6761\u4ef6\u4e3a\u6b62\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p>REPEAT<br \/>\n    &#8212; \u6267\u884c\u7684 SQL \u8bed\u53e5<br \/>\nUNTIL condition<br \/>\nEND REPEAT;<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>DELIMITER $$<\/p>\n<p>CREATE PROCEDURE SumNumbersUsingRepeat(IN n INT)<br \/>\nBEGIN<br \/>\n    DECLARE a INT DEFAULT 0;<br \/>\n    REPEAT<br \/>\n        SET a :&#061; a &#043; n;<br \/>\n        SET n :&#061; n &#8211; 1;<br \/>\n    UNTIL n &lt;&#061; 0<br \/>\n    END REPEAT;<br \/>\n    SELECT a;<br \/>\nEND$$<\/p>\n<p>DELIMITER ;<\/p>\n<h5 id=\"4.6%20LOOP%20%E5%BE%AA%E7%8E%AF\">4.6 LOOP \u5faa\u73af<\/h5>\n<p>LOOP \u5faa\u73af\u662f\u53e6\u4e00\u79cd\u63a7\u5236\u7ed3\u6784&#xff0c;\u9002\u7528\u4e8e\u9700\u8981\u53cd\u590d\u6267\u884c\u67d0\u4e9b\u64cd\u4f5c&#xff0c;\u76f4\u5230\u6ee1\u8db3\u7279\u5b9a\u9000\u51fa\u6761\u4ef6\u65f6\u505c\u6b62\u3002\u4e0e REPEAT \u548c WHILE \u5faa\u73af\u4e0d\u540c&#xff0c;LOOP \u5fc5\u987b\u663e\u5f0f\u4f7f\u7528 LEAVE \u8bed\u53e5\u6765\u9000\u51fa\u5faa\u73af&#xff0c;\u5426\u5219\u5b83\u4f1a\u65e0\u9650\u6267\u884c\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p>loop_label : LOOP<br \/>\n    &#8212; \u6267\u884c\u7684 SQL \u8bed\u53e5<br \/>\n    IF condition THEN<br \/>\n        LEAVE loop_label; &#8212; \u9000\u51fa\u5faa\u73af<br \/>\n    END IF;<br \/>\nEND LOOP;<\/p>\n<p>\u793a\u4f8b&#xff1a;<\/p>\n<p>DELIMITER $$<\/p>\n<p>CREATE PROCEDURE SumOddNumbers(IN n INT)<br \/>\nBEGIN<br \/>\n    DECLARE a INT DEFAULT 0;<br \/>\nsum_loop: LOOP<br \/>\n    IF n % 2 &#061; 0 THEN<br \/>\n        SET n :&#061; n &#8211; 1;<br \/>\n        ITERATE sum_loop;<br \/>\n    END IF;<br \/>\n    SET a :&#061; a &#043; n;<br \/>\n    SET n :&#061; n &#8211; 1;<br \/>\n    IF n &#061; 0 THEN<br \/>\n        LEAVE sum_loop;<br \/>\n    END IF;<br \/>\nEND LOOP;<br \/>\n    SELECT a;<br \/>\nEND$$<\/p>\n<p>DELIMITER ;<\/p>\n<hr \/>\n<h4 id=\"5.%E6%B8%B8%E6%A0%87\">5.\u6e38\u6807<\/h4>\n<p>\u5728 MySQL \u4e2d&#xff0c;\u6e38\u6807&#xff08;Cursor&#xff09;\u662f\u4e00\u79cd\u7528\u4e8e\u904d\u5386\u67e5\u8be2\u7ed3\u679c\u96c6\u7684\u673a\u5236\u3002\u6e38\u6807\u5141\u8bb8\u4f60\u9010\u884c\u5904\u7406\u67e5\u8be2\u7ed3\u679c&#xff0c;\u5bf9\u4e8e\u4e00\u4e9b\u590d\u6742\u7684\u64cd\u4f5c&#xff0c;\u6bd4\u5982\u9010\u884c\u5904\u7406\u6570\u636e\u3001\u8fdb\u884c\u590d\u6742\u7684\u8ba1\u7b97\u7b49&#xff0c;\u6e38\u6807\u975e\u5e38\u6709\u7528\u3002\u901a\u5e38&#xff0c;\u6e38\u6807\u7528\u4e8e\u5b58\u50a8\u8fc7\u7a0b\u4e2d&#xff0c;\u5728\u9700\u8981\u9010\u884c\u5904\u7406\u7ed3\u679c\u96c6\u65f6\u4f7f\u7528\u3002\u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0 \u00a0<\/p>\n<h5 id=\"5.1%C2%A0%C2%A0%E5%A3%B0%E6%98%8E%E6%B8%B8%E6%A0%87\">5.1\u00a0\u00a0\u58f0\u660e\u6e38\u6807<\/h5>\n<p>\u4f7f\u7528 DECLARE \u8bed\u53e5\u58f0\u660e\u6e38\u6807\u3002\u5728\u58f0\u660e\u6e38\u6807\u65f6&#xff0c;\u9700\u8981\u6307\u5b9a\u6e38\u6807\u57fa\u4e8e\u7684\u67e5\u8be2\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p>DECLARE \u6e38\u6807\u540d CURSOR FOR \u67e5\u8be2\u8bed\u53e5;<\/p>\n<h5 id=\"5.2%C2%A0%E6%89%93%E5%BC%80%E6%B8%B8%E6%A0%87\">5.2\u00a0\u6253\u5f00\u6e38\u6807<\/h5>\n<p>\u901a\u8fc7 OPEN \u8bed\u53e5\u6253\u5f00\u6e38\u6807\u5e76\u6267\u884c\u67e5\u8be2\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p>OPEN \u6e38\u6807\u540d;<\/p>\n<h5 id=\"5.3%20%E5%8F%96%E5%87%BA%E6%95%B0%E6%8D%AE\">5.3 \u53d6\u51fa\u6570\u636e<\/h5>\n<p>\u4f7f\u7528 FETCH \u8bed\u53e5\u4ece\u6e38\u6807\u4e2d\u83b7\u53d6\u4e00\u884c\u6570\u636e\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p>FETCH NEXT FROM \u6e38\u6807\u540d INTO \u53d8\u91cf\u5217\u8868;<\/p>\n<p>FETCH \u4f1a\u5c06\u6e38\u6807\u5f53\u524d\u6307\u5411\u7684\u884c\u7684\u6570\u636e\u52a0\u8f7d\u5230\u6307\u5b9a\u7684\u53d8\u91cf\u4e2d\u3002<\/p>\n<h5 id=\"5.4Handler%20(%E5%BC%82%E5%B8%B8%E5%A4%84%E7%90%86%E5%99%A8)\">5.4Handler (\u5f02\u5e38\u5904\u7406\u5668)<\/h5>\n<p>\u5728 MySQL \u4e2d&#xff0c;Handler&#xff08;\u5f02\u5e38\u5904\u7406\u5668&#xff09; \u662f\u4e00\u79cd\u7528\u4e8e\u5904\u7406\u5b58\u50a8\u8fc7\u7a0b\u4e2d\u7684\u5f02\u5e38\u548c\u9519\u8bef\u7684\u673a\u5236\u3002Handler \u53ef\u4ee5\u5e2e\u52a9\u5728\u9047\u5230\u7279\u5b9a\u6761\u4ef6&#xff08;\u5982\u67e5\u8be2\u7ed3\u679c\u4e3a\u7a7a\u3001\u9519\u8bef\u53d1\u751f\u7b49&#xff09;\u65f6&#xff0c;\u81ea\u52a8\u6267\u884c\u6307\u5b9a\u7684\u64cd\u4f5c&#xff0c;\u4ece\u800c\u63d0\u9ad8\u7a0b\u5e8f\u7684\u5065\u58ee\u6027\u548c\u7075\u6d3b\u6027\u3002<\/p>\n<p>MySQL \u63d0\u4f9b\u4e86\u591a\u79cd Handler \u7c7b\u578b&#xff0c;\u4e3b\u8981\u901a\u8fc7 DECLARE \u8bed\u53e5\u58f0\u660e\u3002\u5728\u5b58\u50a8\u8fc7\u7a0b\u4e2d&#xff0c;Handler \u7528\u4e8e\u6355\u83b7\u7279\u5b9a\u6761\u4ef6&#xff08;\u5982\u67e5\u8be2\u6ca1\u6709\u8fd4\u56de\u7ed3\u679c\u3001\u89e6\u53d1\u9519\u8bef\u7b49&#xff09;&#xff0c;\u5e76\u6267\u884c\u76f8\u5e94\u7684\u64cd\u4f5c\u3002<\/p>\n<p>Handler \u673a\u5236\u7684\u76ee\u7684\u662f&#xff1a;\u5f53\u9047\u5230\u5f02\u5e38\u6216\u7279\u5b9a\u6761\u4ef6\u65f6&#xff0c;\u4e0d\u9700\u8981\u8ba9\u5b58\u50a8\u8fc7\u7a0b\u4e2d\u65ad&#xff0c;\u800c\u662f\u53ef\u4ee5\u7ee7\u7eed\u6267\u884c\u540e\u7eed\u7684\u903b\u8f91\u3002<\/p>\n<p>Handler \u7684\u57fa\u672c\u8bed\u6cd5:<\/p>\n<p>DECLARE handler_type HANDLER FOR condition_value action;<\/p>\n<ul>\n<li>\n<p>handler_type&#xff1a;\u6307\u5b9a\u5904\u7406\u5668\u7684\u7c7b\u578b&#xff0c;\u5e38\u89c1\u7684\u7c7b\u578b\u6709&#xff1a;<\/p>\n<ul>\n<li>\n<p>CONTINUE&#xff1a;\u9047\u5230\u5f02\u5e38\u6216\u6761\u4ef6\u65f6\u7ee7\u7eed\u6267\u884c\u540e\u7eed\u8bed\u53e5\u3002<\/p>\n<\/li>\n<li>\n<p>EXIT&#xff1a;\u9047\u5230\u5f02\u5e38\u6216\u6761\u4ef6\u65f6\u9000\u51fa\u5b58\u50a8\u8fc7\u7a0b\u6216\u5faa\u73af\u3002<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>condition_value&#xff1a;\u6307\u5b9a\u6761\u4ef6&#xff0c;\u53ef\u4ee5\u662f&#xff1a;<\/p>\n<ul>\n<li>\n<p>NOT FOUND&#xff1a;\u8868\u793a\u6ca1\u6709\u627e\u5230\u6570\u636e&#xff08;\u901a\u5e38\u4e0e SELECT \u67e5\u8be2\u7ed3\u679c\u4e3a\u7a7a\u65f6\u7ed3\u5408\u4f7f\u7528&#xff09;02\u3002<\/p>\n<\/li>\n<li>\n<p>SQLWARNING&#xff1a;\u8868\u793a SQL \u8b66\u544a\u300201<\/p>\n<\/li>\n<li>\n<p>SQLEXCEPTION&#xff1a;\u8868\u793a SQL \u5f02\u5e38&#xff08;\u5982\u67e5\u8be2\u9519\u8bef\u3001\u63d2\u5165\u5931\u8d25\u7b49&#xff09;&#xff0c;\u966401\u548c02<\/p>\n<\/li>\n<\/ul>\n<\/li>\n<li>\n<p>action&#xff1a;\u5728\u6ee1\u8db3\u6307\u5b9a\u6761\u4ef6\u65f6\u8981\u6267\u884c\u7684\u64cd\u4f5c&#xff0c;\u4f8b\u5982\u8bbe\u7f6e\u53d8\u91cf\u3001\u6253\u5370\u9519\u8bef\u4fe1\u606f\u3001\u9000\u51fa\u7b49\u3002<\/p>\n<\/li>\n<\/ul>\n<p>declare exit handler for sqlstate &#039;02000&#039;;&#8212;&#8212;\u9000\u51fa\u7801\u9000\u51fa<br \/>\ndeclare exit handler for not found ;&#8212;&#8212;&#8212;&#8212;\u672a\u627e\u5230\u9000\u51fa01<br \/>\ndeclare exit handler for sqlwarning;&#8212;&#8212;&#8212;&#8212;sql\u8b66\u544a\u9000\u51fa02 <\/p>\n<h5 id=\"5.4%C2%A0%E5%85%B3%E9%97%AD%E6%B8%B8%E6%A0%87\">5.4\u00a0\u5173\u95ed\u6e38\u6807<\/h5>\n<p>\u5f53\u6570\u636e\u5904\u7406\u5b8c\u6bd5\u540e&#xff0c;\u4f7f\u7528 CLOSE \u8bed\u53e5\u5173\u95ed\u6e38\u6807\u3002<\/p>\n<p>\u8bed\u6cd5&#xff1a;<\/p>\n<p>CLOSE \u6e38\u6807\u540d;<\/p>\n<h5 id=\"5.5%C2%A0%E6%B8%B8%E6%A0%87%E7%9A%84%E5%AE%8C%E6%95%B4%E7%A4%BA%E4%BE%8B\">5.5\u00a0\u6e38\u6807\u7684\u5b8c\u6574\u793a\u4f8b<\/h5>\n<p>\u5b8c\u6574\u7684\u793a\u4f8b&#xff1a;<\/p>\n<p>delimiter ##<br \/>\ncreate procedure s10(in p_sdept varchar(10))<br \/>\nbegin<br \/>\n    declare c_snme varchar(20);<br \/>\n    declare c_sno   varchar(5);<br \/>\n    declare c_birthday date;<br \/>\n    declare c_name cursor for<br \/>\n            select sno,snme,birthday from student where p_sdept&#061;sdept;<br \/>\n    declare exit handler for not found close c_name;<\/p>\n<p>    create table if not exists r1<br \/>\n    ( id varchar(5),<br \/>\n      name varchar(20),<br \/>\n      birthday date<br \/>\n    );<br \/>\n    open c_name;<br \/>\n    while true do<br \/>\n        fetch c_name into c_sno,c_snme,c_birthday;<br \/>\n        insert into r1 values( c_sno,c_snme,c_birthday);<br \/>\n    end while;<br \/>\n    close c_name;<br \/>\nend ##<br \/>\ndelimiter ;   <\/p>\n<h4 id=\"%E2%80%8B%E7%BC%96%E8%BE%91\"><img loading=\"lazy\" decoding=\"async\" alt=\"\" height=\"372\" src=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250429023804-68103b8c850ba.png\" width=\"912\" \/><\/h4>\n<h4 id=\"6.%20%E8%A7%A6%E5%8F%91%E5%99%A8\">6. \u89e6\u53d1\u5668<\/h4>\n<ul>\n<li>\n<p>\u5b9a\u4e49&#xff1a;\u9884\u5148\u7ed1\u5b9a\u5728\u8868\u4e0a\u7684\u4e00\u6bb5 SQL \u4ee3\u7801&#xff0c;\u5f53\u6ee1\u8db3\u6307\u5b9a\u4e8b\u4ef6&#xff08;INSERT\/UPDATE\/DELETE&#xff09;\u5e76\u5230\u8fbe\u6307\u5b9a\u65f6\u673a&#xff08;BEFORE\/AFTER&#xff09;\u65f6&#xff0c;\u7531 MySQL \u81ea\u52a8\u6267\u884c\u3002<\/p>\n<\/li>\n<li>\n<p>\u4f5c\u7528&#xff1a;\u6570\u636e\u6821\u9a8c\u3001\u81ea\u52a8\u8865\u5145\u6d3e\u751f\u5b57\u6bb5\u3001\u5199\u5ba1\u8ba1\u65e5\u5fd7\u3001\u540c\u6b65\u5197\u4f59\u8868\u7b49\u3002<\/p>\n<\/li>\n<li>\n<p>\u6267\u884c\u7c92\u5ea6&#xff1a;MySQL \u53ea\u652f\u6301 \u884c\u7ea7\u89e6\u53d1\u5668&#xff08;FOR EACH ROW&#xff09;&#xff0c;\u6ca1\u6709\u8bed\u53e5\u7ea7\u89e6\u53d1\u5668\u3002\u5bf9\u8868\u91cc\u6bcf\u4e00\u884c\u53d7\u5f71\u54cd\u7684\u8bb0\u5f55\u90fd\u4f1a\u6267\u884c\u4e00\u6b21\u89e6\u53d1\u5668\u4f53\u3002<\/p>\n<\/li>\n<\/ul>\n<h5 id=\"6.1%20%E5%88%9B%E5%BB%BA%E8%A7%A6%E5%8F%91%E5%99%A8\">6.1 \u521b\u5efa\u89e6\u53d1\u5668<\/h5>\n<p>\u521b\u5efa\u89e6\u53d1\u5668\u65f6&#xff0c;\u9996\u5148\u4f7f\u7528 DELIMITER \u4e34\u65f6\u6539\u53d8\u8bed\u53e5\u5206\u9694\u7b26&#xff0c;\u4ee5\u4fbf\u5728\u89e6\u53d1\u5668\u4f53\u5185\u4f7f\u7528\u5206\u53f7\u3002\u7136\u540e&#xff0c;\u901a\u8fc7 CREATE TRIGGER \u8bed\u53e5\u521b\u5efa\u89e6\u53d1\u5668\u3002<\/p>\n<p>DELIMITER $$               &#8212; \u4e34\u65f6\u6362\u5206\u9694\u7b26&#xff0c;\u907f\u514d\u78b0\u5230\u89e6\u53d1\u5668\u4f53\u5185\u7684\u5206\u53f7<\/p>\n<p>CREATE TRIGGER \u89e6\u53d1\u5668\u540d<br \/>\n{BEFORE | AFTER} {INSERT | UPDATE | DELETE}<br \/>\nON \u8868\u540d<br \/>\nFOR EACH ROW<br \/>\nBEGIN<br \/>\n    &#8212; \u89e6\u53d1\u5668\u4f53&#xff1a;\u53ef\u5199\u591a\u6761\u8bed\u53e5<br \/>\n    &#8212; \u53ef\u7528 NEW.\u5217\u540d \u8bbf\u95ee\u201c\u65b0\u503c\u201d<br \/>\n    &#8212; \u53ef\u7528 OLD.\u5217\u540d \u8bbf\u95ee\u201c\u65e7\u503c\u201d&#xff08;\u5bf9\u4e8e INSERT \u6ca1\u65e7\u503c&#xff0c;DELETE \u6ca1\u65b0\u503c&#xff09;<br \/>\nEND$$<\/p>\n<p>DELIMITER ;                &#8212; \u6062\u590d\u9ed8\u8ba4\u5206\u9694\u7b26<\/p>\n<p>\u547d\u540d\u7ea6\u5b9a&#xff1a;\u63a8\u8350 \u8868\u540d_\u4e8b\u4ef6_\u65f6\u673a_trigger&#xff0c;\u5982 student_ai_trigger \u8868\u793a After Insert \u7684\u89e6\u53d1\u5668\u3002<\/p>\n<hr \/>\n<h5 id=\"4.%20%E6%9F%A5%E7%9C%8B%E3%80%81%E5%88%A0%E9%99%A4%E8%A7%A6%E5%8F%91%E5%99%A8\">6.2. \u67e5\u770b\u3001\u5220\u9664\u89e6\u53d1\u5668<\/h5>\n<p>&#8212; \u67e5\u770b\u5f53\u524d\u5e93\u6240\u6709\u89e6\u53d1\u5668<br \/>\nSHOW TRIGGERS\\\\G<\/p>\n<p>&#8212; \u67e5\u770b\u67d0\u89e6\u53d1\u5668\u7684\u521b\u5efa\u8bed\u53e5<br \/>\nSHOW CREATE TRIGGER student_ai_log\\\\G<\/p>\n<p>&#8212; \u5220\u9664\u89e6\u53d1\u5668<br \/>\nDROP TRIGGER IF EXISTS student_ai_log;<\/p>\n<hr \/>\n<h5 id=\"5.%20%E6%B3%A8%E6%84%8F%E4%BA%8B%E9%A1%B9%E4%B8%8E%E5%9D%91\">6.3. \u6ce8\u610f\u4e8b\u9879\u4e0e\u5751<\/h5>\n<table>\n<tr>\u4e3b\u9898\u8bf4\u660e<\/tr>\n<tbody>\n<tr>\n<td>\u6743\u9650<\/td>\n<td>\u9700\u8981 TRIGGER \u6743\u9650&#xff08;\u6216 SUPER&#xff09;\u624d\u80fd\u521b\u5efa\/\u5220\u9664\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u5355\u8868\u540c\u4e8b\u4ef6\u591a\u89e6\u53d1\u5668<\/td>\n<td>MySQL 8.0 \u5141\u8bb8\u540c\u4e00 \u201c\u4e8b\u4ef6&#043;\u65f6\u673a\u201d \u521b\u5efa\u591a\u4e2a\u89e6\u53d1\u5668&#xff0c;\u4f46 5.7 \u53ca\u66f4\u65e9\u7248\u672c\u53ea\u5141\u8bb8\u4e00\u4e2a\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u9012\u5f52\u89e6\u53d1<\/td>\n<td>\u89e6\u53d1\u5668\u91cc\u5bf9\u540c\u4e00\u5f20\u8868\u518d INSERT\/UPDATE\/DELETE \u4f1a\u518d\u6b21\u89e6\u53d1&#xff0c;\u8c28\u9632\u65e0\u9650\u9012\u5f52\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u4e8b\u52a1<\/td>\n<td>\u89e6\u53d1\u5668\u5728\u5f53\u524d\u4e8b\u52a1\u4e2d\u6267\u884c&#xff0c;\u82e5\u89e6\u53d1\u5668\u62a5\u9519&#xff0c;\u6574\u4e2a\u5916\u5c42\u8bed\u53e5\u4f1a\u56de\u6eda\u3002<\/td>\n<\/tr>\n<tr>\n<td>NEW\/OLD \u53ea\u8bfb\u9650\u5236<\/td>\n<td>BEFORE UPDATE \u4e2d\u53ef\u4fee\u6539 NEW.xxx \u6765\u5f71\u54cd\u5373\u5c06\u5199\u5165\u7684\u503c&#xff1b;\u5176\u4ed6\u573a\u666f NEW\/OLD \u5747\u53ea\u8bfb\u3002<\/td>\n<\/tr>\n<tr>\n<td>\u4e0d\u652f\u6301 COMMIT\/ROLLBACK<\/td>\n<td>\u89e6\u53d1\u5668\u4f53\u5185\u7981\u6b62\u663e\u5f0f\u63d0\u4ea4\u6216\u56de\u6eda\u3002<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<p>DELIMITER ##<\/p>\n<p>CREATE TRIGGER tb_user_insert_trigger<br \/>\nAFTER INSERT ON student<br \/>\nFOR EACH ROW<br \/>\nBEGIN<br \/>\n    INSERT INTO user_logs (operation, operate_time, operate_id, operate_params)<br \/>\n    VALUES (<br \/>\n        &#039;insert&#039;,<br \/>\n        NOW(),<br \/>\n        NEW.sno,<br \/>\n        CONCAT(<br \/>\n            &#039;\u63d2\u5165\u7684\u6570\u636e\u5185\u5bb9\u4e3a&#xff1a;sno&#061;&#039;, NEW.sno, &#039;, name&#061;&#039;, NEW.snme<br \/>\n        )<br \/>\n    );<br \/>\nEND##<br \/>\nDELIMITER ; <\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e108\u6b21\uff0c\u6536\u85cf96\u6b21\u3002\u9884\u5148\u7ed1\u5b9a\u5728\u8868\u4e0a\u7684\u4e00\u6bb5 SQL \u4ee3\u7801\uff0c\u5f53\u6ee1\u8db3\u6307\u5b9a\u4e8b\u4ef6\uff08<\/p>\n","protected":false},"author":2,"featured_media":34348,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[1],"tags":[114,100],"topic":[],"class_list":["post-34353","post","type-post","status-publish","format-standard","has-post-thumbnail","hentry","category-server","tag-mysql","tag-100"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v20.3 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>Mysql\u4e4b\u5b58\u50a8\u8fc7\u7a0b\uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3<\/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.wsisp.com\/helps\/34353.html\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"Mysql\u4e4b\u5b58\u50a8\u8fc7\u7a0b\uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"og:description\" content=\"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e108\u6b21\uff0c\u6536\u85cf96\u6b21\u3002\u9884\u5148\u7ed1\u5b9a\u5728\u8868\u4e0a\u7684\u4e00\u6bb5 SQL \u4ee3\u7801\uff0c\u5f53\u6ee1\u8db3\u6307\u5b9a\u4e8b\u4ef6\uff08\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.wsisp.com\/helps\/34353.html\" \/>\n<meta property=\"og:site_name\" content=\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\" \/>\n<meta property=\"article:published_time\" content=\"2025-04-29T02:38:05+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250429023803-68103b8b757c7.png\" \/>\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=\"4 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/34353.html\",\"url\":\"https:\/\/www.wsisp.com\/helps\/34353.html\",\"name\":\"Mysql\u4e4b\u5b58\u50a8\u8fc7\u7a0b\uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"isPartOf\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\"},\"datePublished\":\"2025-04-29T02:38:05+00:00\",\"dateModified\":\"2025-04-29T02:38:05+00:00\",\"author\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\"},\"breadcrumb\":{\"@id\":\"https:\/\/www.wsisp.com\/helps\/34353.html#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.wsisp.com\/helps\/34353.html\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/34353.html#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.wsisp.com\/helps\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"Mysql\u4e4b\u5b58\u50a8\u8fc7\u7a0b\uff08\u4e0b\uff09\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#website\",\"url\":\"https:\/\/www.wsisp.com\/helps\/\",\"name\":\"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3\",\"description\":\"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}\"},\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"zh-Hans\"},{\"@type\":\"Person\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41\",\"name\":\"admin\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"contentUrl\":\"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery\",\"caption\":\"admin\"},\"sameAs\":[\"http:\/\/wp.wsisp.com\"],\"url\":\"https:\/\/www.wsisp.com\/helps\/author\/admin\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"Mysql\u4e4b\u5b58\u50a8\u8fc7\u7a0b\uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","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.wsisp.com\/helps\/34353.html","og_locale":"zh_CN","og_type":"article","og_title":"Mysql\u4e4b\u5b58\u50a8\u8fc7\u7a0b\uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","og_description":"\u6587\u7ae0\u6d4f\u89c8\u9605\u8bfb1k\u6b21\uff0c\u70b9\u8d5e108\u6b21\uff0c\u6536\u85cf96\u6b21\u3002\u9884\u5148\u7ed1\u5b9a\u5728\u8868\u4e0a\u7684\u4e00\u6bb5 SQL \u4ee3\u7801\uff0c\u5f53\u6ee1\u8db3\u6307\u5b9a\u4e8b\u4ef6\uff08","og_url":"https:\/\/www.wsisp.com\/helps\/34353.html","og_site_name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","article_published_time":"2025-04-29T02:38:05+00:00","og_image":[{"url":"https:\/\/www.wsisp.com\/helps\/wp-content\/uploads\/2025\/04\/20250429023803-68103b8b757c7.png"}],"author":"admin","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"admin","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"4 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"WebPage","@id":"https:\/\/www.wsisp.com\/helps\/34353.html","url":"https:\/\/www.wsisp.com\/helps\/34353.html","name":"Mysql\u4e4b\u5b58\u50a8\u8fc7\u7a0b\uff08\u4e0b\uff09 - \u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","isPartOf":{"@id":"https:\/\/www.wsisp.com\/helps\/#website"},"datePublished":"2025-04-29T02:38:05+00:00","dateModified":"2025-04-29T02:38:05+00:00","author":{"@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41"},"breadcrumb":{"@id":"https:\/\/www.wsisp.com\/helps\/34353.html#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.wsisp.com\/helps\/34353.html"]}]},{"@type":"BreadcrumbList","@id":"https:\/\/www.wsisp.com\/helps\/34353.html#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.wsisp.com\/helps"},{"@type":"ListItem","position":2,"name":"Mysql\u4e4b\u5b58\u50a8\u8fc7\u7a0b\uff08\u4e0b\uff09"}]},{"@type":"WebSite","@id":"https:\/\/www.wsisp.com\/helps\/#website","url":"https:\/\/www.wsisp.com\/helps\/","name":"\u7f51\u7855\u4e92\u8054\u5e2e\u52a9\u4e2d\u5fc3","description":"\u9999\u6e2f\u670d\u52a1\u5668_\u9999\u6e2f\u4e91\u670d\u52a1\u5668\u8d44\u8baf_\u670d\u52a1\u5668\u5e2e\u52a9\u6587\u6863_\u670d\u52a1\u5668\u6559\u7a0b","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.wsisp.com\/helps\/?s={search_term_string}"},"query-input":"required name=search_term_string"}],"inLanguage":"zh-Hans"},{"@type":"Person","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/358e386c577a3ab51c4493330a20ad41","name":"admin","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.wsisp.com\/helps\/#\/schema\/person\/image\/","url":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","contentUrl":"https:\/\/gravatar.wp-china-yes.net\/avatar\/?s=96&d=mystery","caption":"admin"},"sameAs":["http:\/\/wp.wsisp.com"],"url":"https:\/\/www.wsisp.com\/helps\/author\/admin"}]}},"_links":{"self":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/34353","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/comments?post=34353"}],"version-history":[{"count":0,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/posts\/34353\/revisions"}],"wp:featuredmedia":[{"embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media\/34348"}],"wp:attachment":[{"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/media?parent=34353"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/categories?post=34353"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/tags?post=34353"},{"taxonomy":"topic","embeddable":true,"href":"https:\/\/www.wsisp.com\/helps\/wp-json\/wp\/v2\/topic?post=34353"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}