{"id":5171,"date":"2024-11-14T10:27:31","date_gmt":"2024-11-14T02:27:31","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5171\/"},"modified":"2024-11-14T10:27:31","modified_gmt":"2024-11-14T02:27:31","slug":"mysql%e6%80%8e%e4%b9%88%e6%b8%85%e7%a9%ba%e6%95%b0%e6%8d%ae","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5171\/","title":{"rendered":"mysql\u600e\u4e48\u6e05\u7a7a\u6570\u636e"},"content":{"rendered":"<blockquote><p>\n  mysql\u63d0\u4f9b\u4e86\u4e09\u79cd\u6e05\u9664\u8868\u4e2d\u6570\u636e\u7684\u9014\u5f84\uff1atruncate table\uff08\u5feb\u901f\u6e05\u7a7a\u6570\u636e\uff0c\u4e0d\u53ef\u9006\u8f6c\uff09\u3001delete from\uff08\u6839\u636e\u6761\u4ef6\u5220\u9664\uff0c\u53ef\u8bb0\u5f55\u64cd\u4f5c\uff09\u3001drop table\uff08\u5220\u9664\u8868\u53ca\u5176\u6240\u6709\u6570\u636e\uff0c\u4e0d\u53ef\u9006\u8f6c\uff09\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/22\/2024052218362395494.jpg\" class=\"aligncenter\" title=\"mysql\u600e\u4e48\u6e05\u7a7a\u6570\u636e\u63d2\u56fe\" alt=\"mysql\u600e\u4e48\u6e05\u7a7a\u6570\u636e\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u6e05\u7a7a MySQL \u6570\u636e<\/strong><\/p>\n<p>MySQL \u63d0\u4f9b\u4e86\u51e0\u79cd\u65b9\u6cd5\u6765\u6e05\u7a7a\u6570\u636e\u8868\u4e2d\u7684\u6570\u636e\uff1a<\/p>\n<p><strong>TRUNCATE TABLE<\/strong><\/p>\n<p>TRUNCATE TABLE \u547d\u4ee4\u7528\u4e8e\u5feb\u901f\u6e05\u7a7a\u8868\u4e2d\u7684\u6240\u6709\u6570\u636e\u3002\u5b83\u6bd4 DELETE \u5feb\uff0c\u56e0\u4e3a\u5b83\u4e0d\u4f1a\u8bb0\u5f55\u5355\u4e2a\u5220\u9664\u64cd\u4f5c\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cTRUNCATE \u662f\u4e0d\u53ef\u9006\u7684\uff0c\u6240\u4ee5\u4f7f\u7528\u524d\u8981\u786e\u4fdd\u6570\u636e\u4e0d\u518d\u9700\u8981\u3002<\/p>\n<p>\u8bed\u6cd5\uff1a<\/p>\n<pre>TRUNCATE TABLE table_name;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>DELETE FROM<\/strong><\/p>\n<p>DELETE FROM \u547d\u4ee4\u7528\u4e8e\u4ece\u8868\u4e2d\u5220\u9664\u7279\u5b9a\u884c\u6216\u6240\u6709\u884c\u3002\u5b83\u6bd4 TRUNCATE \u6162\uff0c\u56e0\u4e3a\u4f1a\u8bb0\u5f55\u6bcf\u4e2a\u5220\u9664\u64cd\u4f5c\u3002<\/p>\n<p>\u8bed\u6cd5\uff1a<\/p>\n<pre>DELETE FROM table_name\nWHERE condition;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p>\u5982\u679c\u8981\u5220\u9664\u6240\u6709\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528 WHERE \u5b50\u53e5\uff1a<\/p>\n<pre>DELETE FROM table_name\nWHERE 1;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u6ce8\u610f\uff1a<\/strong>\u4f7f\u7528 DELETE \u65f6\u8981\u5c0f\u5fc3\uff0c\u56e0\u4e3a\u5b83\u53ef\u80fd\u4f1a\u5f71\u54cd\u5916\u952e\u7ea6\u675f\u3002<\/p>\n<p><strong>DROP TABLE<\/strong><\/p>\n<p>DROP TABLE \u547d\u4ee4\u7528\u4e8e\u5220\u9664\u8868\u53ca\u5176\u6240\u6709\u6570\u636e\u3002\u8fd9\u4e5f\u662f\u4e00\u4e2a\u4e0d\u53ef\u9006\u7684\u64cd\u4f5c\uff0c\u56e0\u6b64\u5728\u4f7f\u7528\u524d\u8981\u5c0f\u5fc3\u3002<\/p>\n<p>\u8bed\u6cd5\uff1a<\/p>\n<pre>DROP TABLE table_name;<\/pre>\n<p> \u767b\u5f55\u540e\u590d\u5236 <\/p>\n<p><strong>\u9009\u62e9\u6700\u4f73\u65b9\u6cd5<\/strong><\/p>\n<p>\u9009\u62e9\u6700\u9002\u5408\u4f60\u7684\u65b9\u6cd5\u53d6\u51b3\u4e8e\u4f60\u7684\u9700\u8981\uff1a<\/p>\n<ul>\n<li>\u5982\u679c\u9700\u8981\u5feb\u901f\u6e05\u7a7a\u8868\u4e14\u4e0d\u9700\u8981\u8bb0\u5f55\u5220\u9664\u64cd\u4f5c\uff0c\u8bf7\u4f7f\u7528 TRUNCATE TABLE\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u6839\u636e\u7279\u5b9a\u6761\u4ef6\u5220\u9664\u6570\u636e\uff0c\u8bf7\u4f7f\u7528 DELETE FROM\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u5220\u9664\u8868\u53ca\u5176\u6240\u6709\u6570\u636e\uff0c\u8bf7\u4f7f\u7528 DROP TABLE\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u600e\u4e48\u6e05\u7a7a\u6570\u636e\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>mysql\u63d0\u4f9b\u4e86\u4e09\u79cd\u6e05\u9664\u8868\u4e2d\u6570\u636e\u7684\u9014\u5f84\uff1atruncate table\uff08\u5feb\u901f\u6e05\u7a7a\u6570\u636e\uff0c\u4e0d\u53ef\u9006\u8f6c\uff09\u3001delete from\uff08\u6839\u636e\u6761\u4ef6\u5220\u9664\uff0c\u53ef\u8bb0\u5f55\u64cd\u4f5c\uff09\u3001drop table\uff08\u5220\u9664\u8868\u53ca\u5176\u6240\u6709\u6570\u636e\uff0c\u4e0d\u53ef\u9006\u8f6c\uff09\u3002 \u5982\u4f55\u6e05\u7a7a MySQL \u6570\u636e MySQL \u63d0\u4f9b\u4e86\u51e0\u79cd\u65b9\u6cd5\u6765\u6e05\u7a7a\u6570\u636e\u8868\u4e2d\u7684\u6570\u636e\uff1a TRUNCATE TABLE TRUNCATE TABLE \u547d\u4ee4\u7528\u4e8e\u5feb\u901f\u6e05\u7a7a\u8868\u4e2d\u7684\u6240\u6709\u6570\u636e\u3002\u5b83\u6bd4 DELETE \u5feb\uff0c\u56e0\u4e3a\u5b83\u4e0d\u4f1a\u8bb0\u5f55\u5355\u4e2a\u5220\u9664\u64cd\u4f5c\u3002\u9700\u8981\u6ce8\u610f\u7684\u662f\uff0cTRUNCATE \u662f\u4e0d\u53ef\u9006\u7684\uff0c\u6240\u4ee5\u4f7f\u7528\u524d\u8981\u786e\u4fdd\u6570\u636e\u4e0d\u518d\u9700\u8981\u3002 \u8bed\u6cd5\uff1a TRUNCATE TABLE table_name; \u767b\u5f55\u540e\u590d\u5236 DELETE FROM DELETE FROM \u547d\u4ee4\u7528\u4e8e\u4ece\u8868\u4e2d\u5220\u9664\u7279\u5b9a\u884c\u6216\u6240\u6709\u884c\u3002\u5b83\u6bd4 TRUNCATE \u6162\uff0c\u56e0\u4e3a\u4f1a\u8bb0\u5f55\u6bcf\u4e2a\u5220\u9664\u64cd\u4f5c\u3002 \u8bed\u6cd5\uff1a DELETE FROM table_name WHERE condition; \u767b\u5f55\u540e\u590d\u5236 \u5982\u679c\u8981\u5220\u9664\u6240\u6709\u884c\uff0c\u53ef\u4ee5\u4f7f\u7528 WHERE \u5b50\u53e5\uff1a DELETE FROM table_name WHERE 1; \u767b\u5f55\u540e\u590d\u5236 \u6ce8\u610f\uff1a\u4f7f\u7528 DELETE \u65f6\u8981\u5c0f\u5fc3\uff0c\u56e0\u4e3a\u5b83\u53ef\u80fd\u4f1a\u5f71\u54cd\u5916\u952e\u7ea6\u675f\u3002 DROP TABLE DROP TABLE \u547d\u4ee4\u7528\u4e8e\u5220\u9664\u8868\u53ca\u5176\u6240\u6709\u6570\u636e\u3002\u8fd9\u4e5f\u662f\u4e00\u4e2a\u4e0d\u53ef\u9006\u7684\u64cd\u4f5c\uff0c\u56e0\u6b64\u5728\u4f7f\u7528\u524d\u8981\u5c0f\u5fc3\u3002 \u8bed\u6cd5\uff1a DROP [&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-5171","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5171","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=5171"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5171\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5171"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5171"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5171"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}