{"id":9119,"date":"2023-11-28T20:54:13","date_gmt":"2023-11-28T12:54:13","guid":{"rendered":"https:\/\/wx.kaifamiao.info\/?p=9119"},"modified":"2023-11-28T20:54:18","modified_gmt":"2023-11-28T12:54:18","slug":"java-zhongsql-zhongdelete-yutruncate-de-qu-bie","status":"publish","type":"post","link":"http:\/\/wx.kaifamiao.info\/index.php\/2023\/11\/28\/java-zhongsql-zhongdelete-yutruncate-de-qu-bie\/","title":{"rendered":"Java\u4e2dSql\u4e2ddelete\u4e0etruncate\u7684\u533a\u522b?"},"content":{"rendered":"<p>1\u3001DELETE \u5c5e\u4e8e\u6570\u636e\u5e93 DML \u64cd\u4f5c\u8bed\u8a00\uff0c\u53ea\u5220\u9664\u6570\u636e\u4e0d\u5220\u9664\u8868\u7684\u7ed3\u6784\uff0c\u4f1a\u8d70\u4e8b\u52a1\uff0c\u6267\u884c\u65f6\u4f1a\u89e6\u53d1 trigger\uff1b<br \/>\n2\u3001\u5728 InnoDB \u4e2d\uff0c DELETE \u5176\u5b9e\u5e76\u4e0d\u4f1a\u771f\u7684\u628a\u6570\u636e\u5220\u9664\uff0cmysql \u5b9e\u9645\u4e0a\u53ea\u662f\u7ed9\u5220\u9664\u7684\u6570\u636e\u6253\u4e86\u4e2a\u6807\u8bb0\u4e3a\u5df2\u5220\u9664\uff0c\u56e0\u6b64 delete \u5220\u9664\u8868\u4e2d\u7684\u6570\u636e\u65f6\uff0c\u8868\u6587\u4ef6\u5728\u78c1\u76d8\u4e0a\u6240\u5360\u7a7a\u95f4\u4e0d\u4f1a\u53d8\u5c0f\uff0c\u5b58\u50a8\u7a7a\u95f4\u4e0d\u4f1a\u88ab\u91ca\u653e\uff0c\u53ea\u662f\u628a\u5220\u9664\u7684\u6570\u636e\u884c\u8bbe\u7f6e\u4e3a\u4e0d\u53ef\u89c1\u3002\u867d\u7136\u672a\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\uff0c\u4f46\u662f\u4e0b\u6b21\u63d2\u5165\u6570\u636e\u7684\u65f6\u5019\uff0c\u4ecd\u7136\u53ef\u4ee5\u91cd\u7528\u8fd9\u90e8\u5206\u7a7a\u95f4\uff08\u91cd\u7528\u2192\u8986\u76d6\uff09\u3002<br \/>\n3\u3001DELETE \u6267\u884c\u65f6\uff0c\u4f1a\u5148\u5c06\u6240\u5220\u9664\u6570\u636e\u7f13\u5b58\u5230 rollback segement \u4e2d\uff0c\u4e8b\u52a1commit \u4e4b\u540e\u751f\u6548\uff1b<br \/>\n4\u3001delete from table_name \u5220\u9664\u8868\u7684\u5168\u90e8\u6570\u636e,\u5bf9\u4e8eMyISAM \u4f1a\u7acb\u523b\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\uff0cInnoDB \u4e0d\u4f1a\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\uff1b<br \/>\n5\u3001\u5bf9\u4e8edelete from table_name where xxx \u5e26\u6761\u4ef6\u7684\u5220\u9664\uff0c\u4e0d\u7ba1\u662fInnoDB\u8fd8\u662f MyISAM \u90fd\u4e0d\u4f1a\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\uff1b<br \/>\n6\u3001delete \u64cd\u4f5c\u4ee5\u540e\u4f7f\u7528 optimize table table_name \u4f1a\u7acb\u523b\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\u3002\u4e0d\u7ba1\u662f InnoDB \u8fd8\u662f MyISAM \u3002\u6240\u4ee5\u8981\u60f3\u8fbe\u5230\u91ca\u653e\u78c1\u76d8\u7a7a\u95f4\u7684\u76ee\u7684\uff0cdelete\u4ee5\u540e\u6267\u884c optimize table \u64cd\u4f5c\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>1\u3001DELETE \u5c5e\u4e8e\u6570\u636e\u5e93 DML \u64cd\u4f5c\u8bed\u8a00\uff0c\u53ea\u5220\u9664\u6570\u636e\u4e0d\u5220\u9664\u8868\u7684\u7ed3\u6784\uff0c\u4f1a\u8d70\u4e8b\u52a1\uff0c\u6267\u884c\u65f6\u4f1a\u89e6\u53d1 trigge [&hellip;]<\/p>\n","protected":false},"author":8,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[99],"tags":[],"class_list":["post-9119","post","type-post","status-publish","format-standard","hentry","category-javabase"],"_links":{"self":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/9119","targetHints":{"allow":["GET"]}}],"collection":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/users\/8"}],"replies":[{"embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/comments?post=9119"}],"version-history":[{"count":1,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/9119\/revisions"}],"predecessor-version":[{"id":9120,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/posts\/9119\/revisions\/9120"}],"wp:attachment":[{"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/media?parent=9119"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/categories?post=9119"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/wx.kaifamiao.info\/index.php\/wp-json\/wp\/v2\/tags?post=9119"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}