{"id":6248,"date":"2024-11-14T08:15:20","date_gmt":"2024-11-14T00:15:20","guid":{"rendered":"https:\/\/fwq.ai\/blog\/6248\/"},"modified":"2024-11-14T08:15:20","modified_gmt":"2024-11-14T00:15:20","slug":"%e5%a6%82%e4%bd%95%e5%88%a0%e9%99%a4mysql%e8%a1%a8%e4%b8%ad%e8%ae%b0%e5%bd%95","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/6248\/","title":{"rendered":"\u5982\u4f55\u5220\u9664mysql\u8868\u4e2d\u8bb0\u5f55"},"content":{"rendered":"<blockquote><p>\n  \u901a\u8fc7\u4f7f\u7528 delete \u547d\u4ee4\uff0c\u60a8\u53ef\u4ee5\u4ece mysql \u8868\u4e2d\u5220\u9664\u8bb0\u5f55\uff0c\u5177\u4f53\u6b65\u9aa4\u5305\u62ec\uff1a\u6307\u5b9a\u8981\u5220\u9664\u8bb0\u5f55\u7684\u8868\u540d\u548c\u6761\u4ef6\uff08\u5982\u679c\u9700\u8981\uff09\uff1b\u63d0\u4ea4\u66f4\u6539\u4ee5\u4fdd\u5b58\u5220\u9664\u64cd\u4f5c\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202406\/15\/2024061516362656179.jpg\" class=\"aligncenter\" title=\"\u5982\u4f55\u5220\u9664mysql\u8868\u4e2d\u8bb0\u5f55\u63d2\u56fe\" alt=\"\u5982\u4f55\u5220\u9664mysql\u8868\u4e2d\u8bb0\u5f55\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u5220\u9664 MySQL \u8868\u4e2d\u8bb0\u5f55<\/strong><\/p>\n<p>\u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u53ef\u4ee5\u5220\u9664 MySQL \u8868\u4e2d\u7684\u8bb0\u5f55\uff1a<\/p>\n<p><strong>1. \u4f7f\u7528 DELETE \u547d\u4ee4<\/strong><br \/>DELETE \u8bed\u53e5\u7528\u4e8e\u4ece\u8868\u4e2d\u5220\u9664\u8bb0\u5f55\u3002\u57fa\u672c\u8bed\u6cd5\u4e3a\uff1a<\/p>\n<pre>DELETE FROM table_name\nWHERE condition;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>table_name \u662f\u8981\u5220\u9664\u8bb0\u5f55\u7684\u8868\u540d<\/li>\n<li>condition \u662f\u7528\u4e8e\u6307\u5b9a\u8981\u5220\u9664\u54ea\u4e9b\u8bb0\u5f55\u7684\u53ef\u9009\u6761\u4ef6<\/li>\n<\/ul>\n<p><strong>2. \u6307\u5b9a\u8981\u5220\u9664\u7684\u8bb0\u5f55<\/strong><br \/>\u4f7f\u7528 WHERE \u5b50\u53e5\u6307\u5b9a\u8981\u5220\u9664\u7684\u7279\u5b9a\u8bb0\u5f55\u3002\u6761\u4ef6\u53ef\u4ee5\u57fa\u4e8e\u4efb\u4f55\u8868\u7684\u5217\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>DELETE FROM users\nWHERE id = 10;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u8bed\u53e5\u4f1a\u4ece users \u8868\u4e2d\u5220\u9664 id \u4e3a 10 \u7684\u8bb0\u5f55\u3002<\/p>\n<p><strong>3. \u5220\u9664\u6240\u6709\u8bb0\u5f55<\/strong><br \/>\u8981\u5220\u9664\u8868\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u53ef\u4ee5\u7701\u7565 WHERE \u5b50\u53e5\u3002\u4f8b\u5982\uff1a<\/p>\n<pre>DELETE FROM users;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>4. \u63d0\u4ea4\u66f4\u6539<\/strong><br \/>\u4f7f\u7528 COMMIT \u8bed\u53e5\u63d0\u4ea4\u5220\u9664\u64cd\u4f5c\u3002\u5982\u679c\u4e0d\u63d0\u4ea4\uff0c\u66f4\u6539\u4e0d\u4f1a\u4fdd\u5b58\u5230\u6570\u636e\u5e93\u4e2d\u3002<\/p>\n<p>\u793a\u4f8b\uff1a<\/p>\n<pre>DELETE FROM users\nWHERE id &gt; 100;\nCOMMIT;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u6b64\u8bed\u53e5\u4f1a\u4ece users \u8868\u4e2d\u5220\u9664 id \u5927\u4e8e 100 \u7684\u6240\u6709\u8bb0\u5f55\u3002<\/p>\n<p>\u4ee5\u4e0a\u5c31\u662f\u5982\u4f55\u5220\u9664\u8868\u4e2d\u8bb0\u5f55\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u901a\u8fc7\u4f7f\u7528 delete \u547d\u4ee4\uff0c\u60a8\u53ef\u4ee5\u4ece mysql \u8868\u4e2d\u5220\u9664\u8bb0\u5f55\uff0c\u5177\u4f53\u6b65\u9aa4\u5305\u62ec\uff1a\u6307\u5b9a\u8981\u5220\u9664\u8bb0\u5f55\u7684\u8868\u540d\u548c\u6761\u4ef6\uff08\u5982\u679c\u9700\u8981\uff09\uff1b\u63d0\u4ea4\u66f4\u6539\u4ee5\u4fdd\u5b58\u5220\u9664\u64cd\u4f5c\u3002 \u5982\u4f55\u5220\u9664 MySQL \u8868\u4e2d\u8bb0\u5f55 \u901a\u8fc7\u4ee5\u4e0b\u6b65\u9aa4\u53ef\u4ee5\u5220\u9664 MySQL \u8868\u4e2d\u7684\u8bb0\u5f55\uff1a 1. \u4f7f\u7528 DELETE \u547d\u4ee4DELETE \u8bed\u53e5\u7528\u4e8e\u4ece\u8868\u4e2d\u5220\u9664\u8bb0\u5f55\u3002\u57fa\u672c\u8bed\u6cd5\u4e3a\uff1a DELETE FROM table_name WHERE condition; \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a table_name \u662f\u8981\u5220\u9664\u8bb0\u5f55\u7684\u8868\u540d condition \u662f\u7528\u4e8e\u6307\u5b9a\u8981\u5220\u9664\u54ea\u4e9b\u8bb0\u5f55\u7684\u53ef\u9009\u6761\u4ef6 2. \u6307\u5b9a\u8981\u5220\u9664\u7684\u8bb0\u5f55\u4f7f\u7528 WHERE \u5b50\u53e5\u6307\u5b9a\u8981\u5220\u9664\u7684\u7279\u5b9a\u8bb0\u5f55\u3002\u6761\u4ef6\u53ef\u4ee5\u57fa\u4e8e\u4efb\u4f55\u8868\u7684\u5217\u3002\u4f8b\u5982\uff1a DELETE FROM users WHERE id = 10; \u767b\u5f55\u540e\u590d\u5236 \u6b64\u8bed\u53e5\u4f1a\u4ece users \u8868\u4e2d\u5220\u9664 id \u4e3a 10 \u7684\u8bb0\u5f55\u3002 3. \u5220\u9664\u6240\u6709\u8bb0\u5f55\u8981\u5220\u9664\u8868\u4e2d\u7684\u6240\u6709\u8bb0\u5f55\uff0c\u53ef\u4ee5\u7701\u7565 WHERE \u5b50\u53e5\u3002\u4f8b\u5982\uff1a DELETE FROM users; \u767b\u5f55\u540e\u590d\u5236 4. [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-6248","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6248","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=6248"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/6248\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=6248"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=6248"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=6248"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}