{"id":2077,"date":"2025-11-20T12:37:13","date_gmt":"2025-11-20T04:37:13","guid":{"rendered":"https:\/\/www.tqazy.com\/?p=2077"},"modified":"2025-11-20T15:07:41","modified_gmt":"2025-11-20T07:07:41","slug":"%e9%9d%a2%e8%af%95%e7%ac%94%e8%ae%b0%ef%bc%9amysql-%e7%9b%b8%e5%85%b301-%e5%9f%ba%e7%a1%80%e6%a0%b8%e5%bf%83","status":"publish","type":"post","link":"https:\/\/www.tqazy.com\/?p=2077","title":{"rendered":"\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517301 &#8211; \u57fa\u7840\u6838\u5fc3"},"content":{"rendered":"<h1>\u57fa\u7840\u6838\u5fc3<\/h1>\n<blockquote>\n<p>\u56de\u76ee\u5f55\uff1a <a href=\"https:\/\/www.tqazy.com\/?p=1972\" target=\"_blank\">\u300a\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u5173\u76ee\u5f55\u300b<\/a><br \/>\n\u4e0b\u4e00\u7bc7\uff1a <a href=\"https:\/\/www.tqazy.com\/?p=2082\" target=\"_blank\">\u300a\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517302 \u2013 \u7d22\u5f15\u300b<\/a><\/p>\n<\/blockquote>\n<hr\/>\n<h1>01. \u6574\u4f53\u67b6\u6784<\/h1>\n<p><div class='fancybox-wrapper lazyload-container-unload' data-fancybox='post-images' href='https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png'><img class=\"lazyload lazyload-style-6\" src=\"data:image\/svg+xml;base64,PCEtLUFyZ29uTG9hZGluZy0tPgo8c3ZnIHdpZHRoPSIxIiBoZWlnaHQ9IjEiIHhtbG5zPSJodHRwOi8vd3d3LnczLm9yZy8yMDAwL3N2ZyIgc3Ryb2tlPSIjZmZmZmZmMDAiPjxnPjwvZz4KPC9zdmc+\"  decoding=\"async\" data-original=\"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png\" src=\"data:image\/png;base64,iVBORw0KGgoAAAANSUhEUgAAAAEAAAABCAYAAAAfFcSJAAAAAXNSR0IArs4c6QAAAARnQU1BAACxjwv8YQUAAAAJcEhZcwAADsQAAA7EAZUrDhsAAAANSURBVBhXYzh8+PB\/AAffA0nNPuCLAAAAAElFTkSuQmCC\" alt=\"\" \/><\/div><\/p>\n<div style=\"height:1em\"><\/div>\n<p>\u4ee55.7\u7248\u672c\u4e3a\u57fa\u7840\uff0c8.0\u7684\u66f4\u6539\u4f1a\u7279\u522b\u6807\u6ce8\u3002<\/p>\n<p>MySQL \u91c7\u7528\u5206\u5c42\u67b6\u6784\uff0c\u6574\u4f53\u53ef\u5206\u4e3a 4 \u5c42\u3002<br \/>\n\u8fde\u63a5\u5c42\u3001\u670d\u52a1\u5c42\u3001\u5b58\u50a8\u5f15\u64ce\u5c42\u3001\u6587\u4ef6\u7cfb\u7edf\u5c42\u3002<\/p>\n<div style=\"height:1em\"><\/div>\n<h2>1. \u8fde\u63a5\u5c42<\/h2>\n<p>\u5ba2\u6237\u7aef\u8fde\u63a5\u5c42<\/p>\n<ul>\n<li>\u8d1f\u8d23\u63a5\u6536\u5ba2\u6237\u7aef\uff08\u5982Java\u7a0b\u5e8f\u3001Navicat\u7b49\uff09\u7684TCP\/IP\u8fde\u63a5\u8bf7\u6c42\uff0c\u5904\u7406\u8eab\u4efd\u8ba4\u8bc1\uff08\u7528\u6237\u540d\u3001\u5bc6\u7801\u3001\u4e3b\u673a\u6743\u9650\u6821\u9a8c\uff09\u3002<\/li>\n<li>\u63d0\u4f9b\u8fde\u63a5\u6c60\u673a\u5236\uff0c\u590d\u7528\u5df2\u5efa\u7acb\u7684\u8fde\u63a5\uff08\u907f\u514d\u9891\u7e41 TCP \u63e1\u624b \/ \u6325\u624b\u7684\u5f00\u9500\uff09\uff0c\u540c\u65f6\u7ba1\u7406\u8fde\u63a5\u72b6\u6001\uff08\u5982\u7a7a\u95f2\u8d85\u65f6\u65ad\u5f00\uff09\u3002<\/li>\n<li>\u6838\u5fc3\u7ec4\u4ef6\uff1a\u8fde\u63a5\u5668\uff08\u9a8c\u8bc1\u7528\u6237\u540d\u5bc6\u7801\u3001\u6743\u9650\uff09\u3001\u8fde\u63a5\u6c60\uff08\u590d\u7528\u5df2\u5efa\u7acb\u7684\u8fde\u63a5\uff0c\u51cf\u5c11\u63e1\u624b\u5f00\u9500\uff09\u3002<\/li>\n<li><strong>8.0\u7248\u672c\u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>\u8ba4\u8bc1\u63d2\u4ef6\u5347\u7ea7\uff1a\u9ed8\u8ba4\u4f7f\u7528<code>caching_sha2_password<\/code>\u66ff\u4ee3 5.7 \u7684<code>mysql_native_password<\/code>\uff0c\u52a0\u5bc6\u5f3a\u5ea6\u66f4\u9ad8\uff0c\u9700\u5ba2\u6237\u7aef\uff08\u5982 JDBC \u9a71\u52a8\uff09\u9002\u914d\u652f\u6301\u3002<\/li>\n<li>\u8fde\u63a5\u6c60\u4f18\u5316\uff1a\u589e\u5f3a\u8fde\u63a5\u590d\u7528\u6548\u7387\uff0c\u51cf\u5c11\u7a7a\u95f2\u8fde\u63a5\u5360\u7528\u7684\u8d44\u6e90\uff0c\u540c\u65f6\u652f\u6301 \u201c\u8fde\u63a5\u5c5e\u6027\u52a8\u6001\u4fee\u6539\u201d\uff08\u65e0\u9700\u91cd\u542f\u8fde\u63a5\u5373\u53ef\u8c03\u6574\u90e8\u5206\u53c2\u6570\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>2. \u670d\u52a1\u5c42<\/h2>\n<p>\u6838\u5fc3\u5904\u7406\u5c42<\/p>\n<ul>\n<li>\u6240\u6709\u5b58\u50a8\u5f15\u64ce\u5171\u4eab\u7684\u6838\u5fc3\u5c42\uff0c\u8d1f\u8d23 SQL \u7684 \u201c\u89e3\u6790 &#8211; \u4f18\u5316 &#8211; \u6267\u884c\u201d \u5168\u6d41\u7a0b\uff0c\u4e0d\u76f4\u63a5\u64cd\u4f5c\u6570\u636e\uff0c\u4ec5\u901a\u8fc7\u63a5\u53e3\u8c03\u7528\u5b58\u50a8\u5f15\u64ce\u3002<\/li>\n<li>\u5305\u542b\u67e5\u8be2\u7f13\u5b58\uff08\u9ed8\u8ba4\u5173\u95ed\uff09\u3001\u89e3\u6790\u5668\u3001\u4f18\u5316\u5668\u3001\u6267\u884c\u5668\u7b49\u6838\u5fc3\u903b\u8f91\u3002<\/li>\n<li>\u7edf\u4e00\u5904\u7406\u65e5\u5fd7\uff08\u5982 binlog\uff09\u3001\u6743\u9650\u4e8c\u6b21\u6821\u9a8c\uff08\u6267\u884c SQL \u524d\u518d\u6b21\u786e\u8ba4\u6743\u9650\uff09\u7b49\u901a\u7528\u903b\u8f91\u3002<\/li>\n<li>\u6838\u5fc3\u6d41\u7a0b\uff1a\u63a5\u6536 SQL \u540e\uff0c\u5148\u67e5\u67e5\u8be2\u7f13\u5b58\uff08\u82e5\u547d\u4e2d\u76f4\u63a5\u8fd4\u56de\uff09\u2192 \u89e3\u6790\u5668\u751f\u6210\u8bed\u6cd5\u6811\uff08\u68c0\u67e5 SQL \u8bed\u6cd5\uff09\u2192 \u4f18\u5316\u5668\u751f\u6210\u6700\u4f18\u6267\u884c\u8ba1\u5212\uff08\u5982\u9009\u62e9\u7d22\u5f15\u3001\u8fde\u63a5\u65b9\u5f0f\uff09\u2192 \u6267\u884c\u5668\u8c03\u7528\u5b58\u50a8\u5f15\u64ce\u63a5\u53e3\u6267\u884c\u8ba1\u5212\u3002<\/li>\n<li><strong>8.0\u7248\u672c\u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>\u79fb\u9664\u67e5\u8be2\u7f13\u5b58\u7ec4\u4ef6\uff1a\u56e0 5.7 \u4e2d\u67e5\u8be2\u7f13\u5b58\u547d\u4e2d\u7387\u6781\u4f4e\uff08\u6570\u636e\u66f4\u65b0\u4f1a\u6e05\u7a7a\u5bf9\u5e94\u8868\u7f13\u5b58\uff09\uff0c8.0 \u76f4\u63a5\u5220\u9664\u8be5\u6a21\u5757\uff0c\u7b80\u5316\u670d\u52a1\u5c42\u903b\u8f91\uff0c\u907f\u514d\u65e0\u6548\u5f00\u9500\u3002<\/li>\n<li>\u4f18\u5316\u5668\u589e\u5f3a\uff1a\u67b6\u6784\u5c42\u9762\u652f\u6301\u66f4\u591a\u4f18\u5316\u89c4\u5219\uff08\u5982\u590d\u6742 JOIN \u7684\u6267\u884c\u8ba1\u5212\u8c03\u6574\uff09\u3002<\/li>\n<li>binlog \u9ed8\u8ba4\u5f00\u542f\uff1a5.7 \u4e2d binlog \u9ed8\u8ba4\u5173\u95ed\uff0c8.0 \u9ed8\u8ba4\u542f\u7528\uff0c\u4e14\u67b6\u6784\u4e0a\u652f\u6301 binlog \u7684 \u201c\u5373\u65f6\u56de\u653e\u201d\uff08\u52a0\u901f\u4e3b\u4ece\u540c\u6b65\uff09\uff0c\u65e0\u9700\u989d\u5916\u914d\u7f6e\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>3. \u5b58\u50a8\u5f15\u64ce\u5c42<\/h2>\n<p>\u6570\u636e\u5b58\u50a8\u5c42<\/p>\n<ul>\n<li>\u91c7\u7528 \u201c\u63d2\u4ef6\u5f0f\u67b6\u6784\u201d\uff0c\u53ef\u52a8\u6001\u52a0\u8f7d\u4e0d\u540c\u5b58\u50a8\u5f15\u64ce\uff08\u5982 InnoDB\u3001MyISAM\uff09\uff0c\u8d1f\u8d23\u6570\u636e\u7684\u5b9e\u9645\u5b58\u50a8\u3001\u8bfb\u53d6\u548c\u4e8b\u52a1\u7ba1\u7406\u3002<\/li>\n<li>\u4e0e\u670d\u52a1\u5c42\u901a\u8fc7\u7edf\u4e00\u7684<code>handler<\/code>\u63a5\u53e3\u4ea4\u4e92\uff0c\u670d\u52a1\u5c42\u65e0\u9700\u5173\u5fc3\u5e95\u5c42\u6570\u636e\u5b58\u50a8\u683c\u5f0f\uff08\u5982 InnoDB \u7684\u8868\u7a7a\u95f4\u3001MyISAM \u7684\u6587\u4ef6\u5b58\u50a8\uff09\u3002<\/li>\n<li>\u9ed8\u8ba4\u5b58\u50a8\u5f15\u64ce\u4e3a InnoDB\uff0c\u67b6\u6784\u4e0a\u652f\u6301\u4e8b\u52a1\u3001\u884c\u9501\u7b49\u7279\u6027\u7684\u5e95\u5c42\u5b9e\u73b0\u3002<\/li>\n<li><strong>8.0\u7248\u672c\u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>\u5f3a\u5316 InnoDB \u7684\u67b6\u6784\u9002\u914d\uff1a\u79fb\u9664\u5176\u4ed6\u4f4e\u6548\u5b58\u50a8\u5f15\u64ce\uff08\u5982 Federated\uff09\uff0c\u4ec5\u4fdd\u7559 InnoDB\u3001MyISAM\u3001Memory \u7b49\u5e38\u7528\u5f15\u64ce\uff0c\u805a\u7126 InnoDB \u7684\u6027\u80fd\u4f18\u5316\u3002<\/li>\n<li>\u67b6\u6784\u5c42\u9762\u652f\u6301 InnoDB \u7684\u65b0\u7279\u6027\uff1a\u5982\u81ea\u589e ID \u6301\u4e45\u5316\uff08\u901a\u8fc7 redo log \u67b6\u6784\u5b9e\u73b0\uff09\u3001\u9690\u85cf\u7d22\u5f15\uff08\u67b6\u6784\u4e0a\u652f\u6301\u7d22\u5f15\u7684 \u201c\u903b\u8f91\u7981\u7528\u201d\uff0c\u4e0d\u5f71\u54cd\u7269\u7406\u5b58\u50a8\uff09\u3002<\/li>\n<li>\u9501\u673a\u5236\u67b6\u6784\u4f18\u5316\uff1a\u884c\u9501\u7684\u8303\u56f4\u5224\u65ad\u903b\u8f91\u5728\u67b6\u6784\u5c42\u9762\u66f4\u7cbe\u51c6\uff0c\u51cf\u5c11\u9501\u51b2\u7a81\uff08\u4f9d\u8d56\u4e0e\u670d\u52a1\u5c42\u7684\u63a5\u53e3\u4ea4\u4e92\u4f18\u5316\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>4. \u6587\u4ef6\u7cfb\u7edf\u5c42<\/h2>\n<ul>\n<li>\u8d1f\u8d23\u5c06\u6570\u636e\u3001\u65e5\u5fd7\u7b49\u6301\u4e45\u5316\u5230\u78c1\u76d8\uff0c\u4f9d\u8d56\u64cd\u4f5c\u7cfb\u7edf\u7684\u6587\u4ef6\u7cfb\u7edf\uff08\u5982 ext4\u3001NTFS\uff09\u3002<\/li>\n<li>\u5b58\u50a8\u6587\u4ef6\u7c7b\u578b\u5305\u62ec\uff1a\u8868\u7a7a\u95f4\u6587\u4ef6\uff08InnoDB \u7684<code>.ibd<\/code>\uff09\u3001\u65e5\u5fd7\u6587\u4ef6\uff08redo log\uff08\u91cd\u505a\u65e5\u5fd7\uff09\u3001binlog\uff08\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff09\u3001undo log\uff08\u56de\u6eda\u65e5\u5fd7\uff09\uff09\u3001\u914d\u7f6e\u6587\u4ef6\uff08my.cnf\uff09\u7b49\u3002<\/li>\n<li><strong>8.0\u7248\u672c\u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>\u65e5\u5fd7\u6587\u4ef6\u67b6\u6784\u8c03\u6574\uff1aredo log \u9ed8\u8ba4\u5b58\u50a8\u8def\u5f84\u4f18\u5316\uff0c\u652f\u6301\u66f4\u5927\u7684\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\uff08\u9ed8\u8ba4\u5355\u4e2a\u6587\u4ef6 1GB\uff0c5.7 \u9ed8\u8ba4 48MB\uff09\uff0c\u63d0\u5347\u5d29\u6e83\u6062\u590d\u6548\u7387\u3002<\/li>\n<li>\u8868\u7a7a\u95f4\u6587\u4ef6\u4f18\u5316\uff1a\u9ed8\u8ba4\u4f7f\u7528\u72ec\u7acb\u8868\u7a7a\u95f4\uff085.7 \u9700\u624b\u52a8\u914d\u7f6e\uff09\uff0c\u4e14\u67b6\u6784\u4e0a\u652f\u6301 \u201c\u8868\u7a7a\u95f4\u52a0\u5bc6\u201d\uff08\u900f\u660e\u6570\u636e\u52a0\u5bc6 TDE\uff09\uff0c\u6587\u4ef6\u5b58\u50a8\u66f4\u5b89\u5168\u3002<\/li>\n<li>\u81ea\u589e ID \u5b58\u50a8\u67b6\u6784\u53d8\u66f4\uff1a5.7 \u4e2d\u81ea\u589e ID \u5b58\u4e8e\u5185\u5b58\uff0c8.0 \u67b6\u6784\u4e0a\u6539\u4e3a\u5199\u5165 redo log\uff0c\u91cd\u542f\u540e\u53ef\u901a\u8fc7\u65e5\u5fd7\u6062\u590d\u81ea\u589e ID \u5e8f\u5217\uff0c\u907f\u514d\u91cd\u590d\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1.5em\"><\/div>\n<h1>02. \u6838\u5fc3\u7ec4\u4ef6<\/h1>\n<h2>1. \u8fde\u63a5\u5668<\/h2>\n<p>Connection Manager<br \/>\n<strong>\u6838\u5fc3\u529f\u80fd\uff1a<\/strong>\u8d1f\u8d23\u5ba2\u6237\u7aef\u8fde\u63a5\u7684\u5efa\u7acb\u3001\u7ba1\u7406\u4e0e\u8eab\u4efd\u8ba4\u8bc1\uff0c\u662f\u5ba2\u6237\u7aef\u4e0e MySQL \u4ea4\u4e92\u7684 \u201c\u5165\u53e3\u201d\u3002<\/p>\n<ul>\n<li>\u63a5\u6536 TCP \u8fde\u63a5\u8bf7\u6c42\u540e\uff0c\u6821\u9a8c\u7528\u6237\u540d\u3001\u5bc6\u7801\u53ca\u5ba2\u6237\u7aef\u4e3b\u673a\u6743\u9650\uff08\u57fa\u4e8emysql.user\u8868\uff09\uff0c\u901a\u8fc7\u540e\u5206\u914d\u8fde\u63a5\u7ebf\u7a0b\u3002<\/li>\n<li>\u7ef4\u62a4\u8fde\u63a5\u72b6\u6001\uff08\u5982\u7a7a\u95f2\u3001\u6d3b\u8dc3\uff09\uff0c\u9ed8\u8ba4\u7a7a\u95f2\u8d85\u65f6\u65f6\u95f4\u4e3a 8 \u5c0f\u65f6\uff08wait_timeout\u53c2\u6570\u63a7\u5236\uff09\uff0c\u8d85\u65f6\u540e\u81ea\u52a8\u65ad\u5f00\u3002<\/li>\n<li>\u8ba4\u8bc1\u4f9d\u8d56<code>mysql_native_password<\/code>\u63d2\u4ef6\uff08\u9ed8\u8ba4\uff09\uff0c\u52a0\u5bc6\u5f3a\u5ea6\u4e00\u822c\uff0c\u517c\u5bb9\u6027\u597d\u3002<\/li>\n<li><strong>8.0 \u7248\u672c\u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>\u9ed8\u8ba4\u8ba4\u8bc1\u63d2\u4ef6\u5347\u7ea7\u4e3a<code>caching_sha2_password<\/code>\uff0c\u91c7\u7528 SHA-256 \u52a0\u5bc6\uff0c\u5b89\u5168\u6027\u66f4\u9ad8\uff08\u9700\u5ba2\u6237\u7aef\u9a71\u52a8\u652f\u6301\uff0c\u5982 JDBC \u9700 8.0 + \u7248\u672c\uff09\u3002<\/li>\n<li>\u4f18\u5316\u8fde\u63a5\u590d\u7528\u673a\u5236\uff0c\u51cf\u5c11\u7a7a\u95f2\u8fde\u63a5\u7684\u8d44\u6e90\u5360\u7528\uff0c\u652f\u6301 \u201c\u8fde\u63a5\u5c5e\u6027\u52a8\u6001\u4fee\u6539\u201d\uff08\u5982\u65e0\u9700\u91cd\u8fde\u5373\u53ef\u8c03\u6574\u90e8\u5206\u4f1a\u8bdd\u53c2\u6570\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>2. \u67e5\u8be2\u7f13\u5b58<\/h2>\n<p>Query Cache<br \/>\n<strong>\u6838\u5fc3\u529f\u80fd\uff1a<\/strong>\u7f13\u5b58 SQL \u8bed\u53e5\u4e0e\u7ed3\u679c\u96c6\uff0c\u76f8\u540c SQL\uff08\u5b57\u8282\u7ea7\u4e00\u81f4\uff09\u53ef\u76f4\u63a5\u8fd4\u56de\u7f13\u5b58\u7ed3\u679c\uff0c\u51cf\u5c11\u91cd\u590d\u8ba1\u7b97\u3002<\/p>\n<ul>\n<li>\u5b58\u5728\u4f46\u9ed8\u8ba4\u5173\u95ed\uff08<code>query_cache_type=OFF<\/code>\uff09\uff0c\u9700\u624b\u52a8\u5f00\u542f\uff1b\u7f13\u5b58\u4ee5\u8868\u4e3a\u5355\u4f4d\uff0c\u8868\u6570\u636e\u66f4\u65b0\uff08\u589e\u5220\u6539\uff09\u65f6\u4f1a\u6e05\u7a7a\u8be5\u8868\u6240\u6709\u7f13\u5b58\u3002<\/li>\n<li>\u5c40\u9650\u6027\u660e\u663e\uff1a\u4ec5\u9002\u7528\u4e8e\u9759\u6001\u6570\u636e\uff08\u5982\u914d\u7f6e\u8868\uff09\uff0c\u9ad8\u5e76\u53d1\u5199\u573a\u666f\u4e0b\u547d\u4e2d\u7387\u6781\u4f4e\uff0c\u53cd\u800c\u56e0\u7f13\u5b58\u7ef4\u62a4\u6d88\u8017\u8d44\u6e90\u3002<\/li>\n<li><strong>8.0 \u7248\u672c\u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>\u5f7b\u5e95\u79fb\u9664\u67e5\u8be2\u7f13\u5b58\u7ec4\u4ef6\uff08\u76f8\u5173\u53c2\u6570\u5982<code>query_cache_size<\/code>\u5931\u6548\uff09\uff0c\u539f\u56e0\u662f\u5176\u5b9e\u9645\u5e94\u7528\u4ef7\u503c\u4f4e\uff0c\u79fb\u9664\u540e\u7b80\u5316\u4e86\u670d\u52a1\u5c42\u903b\u8f91\uff0c\u51cf\u5c11\u65e0\u6548\u5f00\u9500\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>3. \u89e3\u6790\u5668<\/h2>\n<p>Parser<br \/>\n<strong>\u6838\u5fc3\u529f\u80fd\uff1a<\/strong>\u5bf9 SQL \u8bed\u53e5\u8fdb\u884c\u8bed\u6cd5\u5206\u6790\uff0c\u751f\u6210 \u201c\u8bed\u6cd5\u6811\u201d\uff0c\u786e\u4fdd SQL \u7b26\u5408\u8bed\u6cd5\u89c4\u5219\u3002<\/p>\n<ul>\n<li>\u89e3\u6790\u8fc7\u7a0b\u5305\u62ec\uff1a\u8bcd\u6cd5\u5206\u6790\uff08\u8bc6\u522b\u5173\u952e\u5b57\u3001\u8868\u540d\u3001\u5b57\u6bb5\u540d\u7b49\uff09\u2192 \u8bed\u6cd5\u5206\u6790\uff08\u68c0\u67e5 SQL \u7ed3\u6784\u662f\u5426\u5408\u6cd5\uff0c\u5982<code>SELECT<\/code>\u540e\u662f\u5426\u6709\u5b57\u6bb5\u3001<code>WHERE<\/code>\u662f\u5426\u642d\u914d\u6761\u4ef6\uff09\u3002<\/li>\n<li>\u82e5\u8bed\u6cd5\u9519\u8bef\uff08\u5982\u5173\u952e\u5b57\u62fc\u5199\u9519\u8bef\uff09\uff0c\u76f4\u63a5\u8fd4\u56de\u62a5\u9519\uff08\u5982 \u201cyou have an error in your SQL syntax\u201d\uff09\u3002<\/li>\n<li><strong>8.0 \u7248\u672c\u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>\u6838\u5fc3\u529f\u80fd\u4e0d\u53d8\uff0c\u4f46\u6269\u5c55\u4e86\u5bf9\u65b0\u8bed\u6cd5\u7684\u652f\u6301\uff08\u5982<code>WITH RECURSIVE<\/code>\u9012\u5f52\u67e5\u8be2\u3001\u964d\u5e8f\u7d22\u5f15\u8bed\u6cd5\uff09\uff0c\u89e3\u6790\u6548\u7387\u7565\u6709\u4f18\u5316\uff08\u51cf\u5c11\u8bed\u6cd5\u6811\u751f\u6210\u7684\u5185\u5b58\u5360\u7528\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>4. \u4f18\u5316\u5668<\/h2>\n<p>Optimizer<br \/>\n<strong>\u6838\u5fc3\u529f\u80fd\uff1a<\/strong>\u57fa\u4e8e\u8bed\u6cd5\u6811\u751f\u6210 \u201c\u6700\u4f18\u6267\u884c\u8ba1\u5212\u201d\uff0c\u76ee\u6807\u662f\u6700\u5c0f\u5316\u6267\u884c\u6210\u672c\uff08CPU\u3001IO \u5f00\u9500\uff09\u3002<\/p>\n<ul>\n<li>\u4f18\u5316\u903b\u8f91\u5305\u62ec\uff1a\u9009\u62e9\u5408\u9002\u7684\u7d22\u5f15\uff08\u5982\u5224\u65ad\u5168\u8868\u626b\u63cf vs \u7d22\u5f15\u626b\u63cf\u66f4\u5feb\uff09\u3001\u8c03\u6574\u591a\u8868\u8fde\u63a5\u987a\u5e8f\uff08\u5c0f\u8868\u9a71\u52a8\u5927\u8868\u51cf\u5c11\u4e2d\u95f4\u7ed3\u679c\u96c6\uff09\u3001\u7b80\u5316\u8868\u8fbe\u5f0f\uff08\u5982<code>a=1 and a=2<\/code>\u76f4\u63a5\u5224\u5b9a\u4e3a\u65e0\u6548\uff09\u3002<\/li>\n<li>\u4f9d\u8d56\u8868\u7edf\u8ba1\u4fe1\u606f\uff08\u5982\u884c\u6570\u3001\u6570\u636e\u5206\u5e03\uff09\uff0c\u4f46\u7edf\u8ba1\u4fe1\u606f\u66f4\u65b0\u4e0d\u53ca\u65f6\u53ef\u80fd\u5bfc\u81f4\u6267\u884c\u8ba1\u5212\u504f\u5dee\u3002<\/li>\n<li><strong>8.0 \u7248\u672c\u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>\u589e\u5f3a\u7edf\u8ba1\u4fe1\u606f\uff1a\u5f15\u5165 \u201c\u76f4\u65b9\u56fe\u201d\uff08Histogram\uff09\uff0c\u66f4\u7cbe\u51c6\u8bb0\u5f55\u6570\u636e\u5206\u5e03\uff08\u5982\u5b57\u6bb5\u503c\u7684\u9891\u7387\uff09\uff0c\u4f18\u5316\u5668\u5bf9\u975e\u5747\u5300\u5206\u5e03\u6570\u636e\u7684\u7d22\u5f15\u9009\u62e9\u66f4\u5408\u7406\u3002<\/li>\n<li>\u4f18\u5316\u89c4\u5219\u6269\u5c55\uff1a\u652f\u6301\u590d\u6742 JOIN\uff08\u5982\u591a\u8868\u5d4c\u5957\u8fde\u63a5\uff09\u7684\u6267\u884c\u8ba1\u5212\u8c03\u6574\uff0c\u5b50\u67e5\u8be2\u4f18\u5316\u66f4\u5f7b\u5e95\uff08\u51cf\u5c11 \u201c\u6d3e\u751f\u8868\u201d \u7684\u4e34\u65f6\u8868\u5f00\u9500\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>5. \u6267\u884c\u5668<\/h2>\n<p>Executor<br \/>\n<strong>\u6838\u5fc3\u529f\u80fd\uff1a<\/strong>\u6839\u636e\u4f18\u5316\u5668\u751f\u6210\u7684\u6267\u884c\u8ba1\u5212\uff0c\u8c03\u7528\u5b58\u50a8\u5f15\u64ce\u63a5\u53e3\u6267\u884c\u64cd\u4f5c\uff0c\u5e76\u8fd4\u56de\u7ed3\u679c\u3002<\/p>\n<ul>\n<li>\u6267\u884c\u524d\u518d\u6b21\u6821\u9a8c\u6743\u9650\uff08\u907f\u514d\u8fde\u63a5\u5efa\u7acb\u540e\u6743\u9650\u88ab\u4fee\u6539\u5bfc\u81f4\u7684\u5b89\u5168\u95ee\u9898\uff09\u3002\n<ul>\n<li>\u4f8b\u5982\uff1a\u68c0\u67e5\u7528\u6237\u662f\u5426\u6709\u76ee\u6807\u8868\u7684<code>SELECT<\/code>\u6743\u9650\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u901a\u8fc7\u7edf\u4e00\u63a5\u53e3\uff08\u5982<code>handler::read_row<\/code>\uff09\u8c03\u7528\u5b58\u50a8\u5f15\u64ce\uff0c\u83b7\u53d6\u6570\u636e\u540e\u8fdb\u884c\u8fc7\u6ee4\u3001\u805a\u5408\u7b49\u5904\u7406\uff08\u5982<code>WHERE<\/code>\u6761\u4ef6\u8fc7\u6ee4\u3001<code>GROUP BY<\/code>\u5206\u7ec4\uff09\u3002<\/li>\n<li><strong>8.0 \u7248\u672c\u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>\u4f18\u5316\u63a5\u53e3\u8c03\u7528\u6548\u7387\uff0c\u51cf\u5c11\u4e0e\u5b58\u50a8\u5f15\u64ce\u7684\u4ea4\u4e92\u6b21\u6570\uff08\u5982\u6279\u91cf\u8bfb\u53d6\u6570\u636e\uff09\u3002<\/li>\n<li>\u652f\u6301 \u201c\u5373\u65f6\u6267\u884c\u201d\uff08Instant Execution\uff09\uff0c\u5bf9\u7b80\u5355\u67e5\u8be2\u53ef\u8df3\u8fc7\u90e8\u5206\u4f18\u5316\u6b65\u9aa4\uff0c\u76f4\u63a5\u6267\u884c\uff0c\u63d0\u5347\u54cd\u5e94\u901f\u5ea6\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>6. \u65e5\u5fd7\u7ec4\u4ef6<\/h2>\n<p>\u6838\u5fc3\u65e5\u5fd7\u6a21\u5757<br \/>\n\u8d1f\u8d23\u8bb0\u5f55 MySQL \u7684\u64cd\u4f5c\u548c\u72b6\u6001\uff0c\u652f\u6491\u6570\u636e\u6062\u590d\u3001\u4e3b\u4ece\u540c\u6b65\u7b49\u529f\u80fd\u3002<\/p>\n<p><strong>1. binlog\uff08\u4e8c\u8fdb\u5236\u65e5\u5fd7\uff09<\/strong><\/p>\n<ul>\n<li><strong>5.7 \u7248\u672c\uff1a<\/strong>\u9ed8\u8ba4\u5173\u95ed\uff0c\u9700\u624b\u52a8\u5f00\u542f\uff08<code>log_bin=ON<\/code>\uff09\u3002\u8bb0\u5f55\u6240\u6709\u6570\u636e\u4fee\u6539\u64cd\u4f5c\uff08\u589e\u5220\u6539\u3001DDL\uff09\uff0c\u683c\u5f0f\u652f\u6301<code>STATEMENT<\/code>\uff08\u8bed\u53e5\uff09\u3001<code>ROW<\/code>\uff08\u884c\uff09\u3001<code>MIXED<\/code>\uff08\u6df7\u5408\uff09\uff0c\u7528\u4e8e\u4e3b\u4ece\u540c\u6b65\u548c\u65f6\u95f4\u70b9\u6062\u590d\u3002<\/li>\n<li><strong>8.0 \u7248\u672c\uff1a<\/strong>\u9ed8\u8ba4\u5f00\u542f\u3002\u683c\u5f0f\u9ed8\u8ba4<code>ROW<\/code>\uff08\u66f4\u5b89\u5168\uff09\uff0c\u652f\u6301 \u201c\u5373\u65f6\u56de\u653e\u201d\uff08Binlog Instant\uff09\uff0c\u4e3b\u4ece\u540c\u6b65\u65f6\u53ef\u8df3\u8fc7\u90e8\u5206\u65e0\u6548\u65e5\u5fd7\uff0c\u63d0\u5347\u540c\u6b65\u6548\u7387\u3002<\/li>\n<\/ul>\n<p><strong>2. redo log\uff08\u91cd\u505a\u65e5\u5fd7\uff0cInnoDB \u4f9d\u8d56\uff09<\/strong><\/p>\n<ul>\n<li><strong>5.7 \u7248\u672c\uff1a<\/strong>InnoDB \u4e13\u5c5e\uff0c\u8bb0\u5f55\u6570\u636e\u9875\u7684\u7269\u7406\u4fee\u6539\uff0c\u91c7\u7528 \u201c\u5faa\u73af\u5199\u201d \u673a\u5236\uff08\u56fa\u5b9a\u5927\u5c0f\u6587\u4ef6\uff09\uff0c\u4fdd\u8bc1\u5d29\u6e83\u540e\u6570\u636e\u53ef\u6062\u590d\uff08\u5148\u5199\u65e5\u5fd7\u518d\u5199\u78c1\u76d8\uff0c\u5373 WAL \u673a\u5236\uff09\u3002<\/li>\n<li><strong>8.0 \u7248\u672c\uff1a<\/strong>\u9ed8\u8ba4\u5355\u4e2a\u65e5\u5fd7\u6587\u4ef6\u5927\u5c0f\u4ece 48MB \u589e\u81f3 1GB\uff0c\u51cf\u5c11\u65e5\u5fd7\u5207\u6362\u9891\u7387\uff1b\u652f\u6301 \u201c\u5e76\u884c\u5199\u5165\u201d\uff0c\u63d0\u5347\u9ad8\u5e76\u53d1\u4e0b\u7684\u65e5\u5fd7\u5199\u5165\u6548\u7387\u3002<\/li>\n<\/ul>\n<p><strong>3. undo log\uff08\u56de\u6eda\u65e5\u5fd7\uff0cInnoDB \u4f9d\u8d56\uff09<\/strong><\/p>\n<ul>\n<li><strong>5.7 \u7248\u672c\uff1a<\/strong>\u8bb0\u5f55\u6570\u636e\u4fee\u6539\u524d\u7684\u72b6\u6001\uff0c\u7528\u4e8e\u4e8b\u52a1\u56de\u6eda\u548c MVCC\uff08\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\uff09\uff0c\u9ed8\u8ba4\u968f\u8868\u7a7a\u95f4\u5b58\u50a8\uff0c\u53ef\u80fd\u56e0\u957f\u671f\u79ef\u7d2f\u5bfc\u81f4\u7a7a\u95f4\u81a8\u80c0\u3002<\/li>\n<li><strong>8.0 \u7248\u672c\uff1a<\/strong>\u652f\u6301 \u201cundo log \u81ea\u52a8\u56de\u6536\u201d\uff08\u901a\u8fc7<code>innodb_undo_log_truncate<\/code>\u53c2\u6570\uff09\uff0c\u65e0\u9700\u624b\u52a8\u6e05\u7406\uff0c\u51cf\u5c11\u7ef4\u62a4\u6210\u672c\u3002<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>7. \u6743\u9650\u7ec4\u4ef6<\/h2>\n<p><strong>\u6838\u5fc3\u529f\u80fd\uff1a<\/strong>\u7ba1\u7406\u7528\u6237\u6743\u9650\uff0c\u63a7\u5236\u5bf9\u6570\u636e\u5e93\u3001\u8868\u3001\u5b57\u6bb5\u7684\u64cd\u4f5c\u6743\u9650\u3002<\/p>\n<ul>\n<li>\u6743\u9650\u5b58\u50a8\u5728<code>mysql<\/code>\u5e93\u7684\u7cfb\u7edf\u8868\u4e2d\uff08\u5982<code>user<\/code>\u3001<code>db<\/code>\u3001<code>tables_priv<\/code>\uff09\uff0c\u6743\u9650\u4fee\u6539\u540e\u9700\u901a\u8fc7<code>FLUSH PRIVILEGES<\/code>\u5237\u65b0\u6216\u91cd\u542f\u751f\u6548\uff08\u9759\u6001\u6743\u9650\uff09\u3002<\/li>\n<li>\u652f\u6301\u5e93\u7ea7\u3001\u8868\u7ea7\u3001\u5217\u7ea7\u6743\u9650\uff0c\u4f46\u7f3a\u4e4f\u7ec6\u7c92\u5ea6\u7684\u52a8\u6001\u6743\u9650\uff08\u5982\u7ba1\u7406\u7279\u5b9a\u65e5\u5fd7\u7684\u6743\u9650\uff09\u3002<\/li>\n<li><strong>8.0 \u7248\u672c\u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>\u5f15\u5165 \u201c\u52a8\u6001\u6743\u9650\u201d\uff08\u5982<code>BINLOG_ADMIN<\/code>\u3001<code>BACKUP_ADMIN<\/code>\uff09\uff0c\u6743\u9650\u4fee\u6539\u540e\u5373\u65f6\u751f\u6548\uff0c\u65e0\u9700\u5237\u65b0\u6216\u91cd\u542f\u3002<\/li>\n<li>\u6743\u9650\u68c0\u67e5\u903b\u8f91\u4f18\u5316\uff0c\u7ed3\u5408\u89d2\u8272\uff08Role\uff09\u7ba1\u7406\uff085.7 \u540e\u671f\u5f15\u5165\u4f46\u4e0d\u5b8c\u5584\uff0c8.0 \u5f3a\u5316\uff09\uff0c\u53ef\u6279\u91cf\u5206\u914d\u6743\u9650\uff0c\u7b80\u5316\u6743\u9650\u7ba1\u7406\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>8. \u603b\u7ed3<\/h2>\n<p>MySQL \u6838\u5fc3\u7ec4\u4ef6\u7684\u6838\u5fc3\u903b\u8f91\uff08\u8fde\u63a5\u3001\u89e3\u6790\u3001\u4f18\u5316\u3001\u6267\u884c\u3001\u65e5\u5fd7\u3001\u6743\u9650\uff09\u5728 5.7 \u548c 8.0 \u4e2d\u4fdd\u6301\u4e00\u81f4\u3002<br \/>\n8.0 \u7684\u6539\u8fdb\u96c6\u4e2d\u5728\uff1a\u79fb\u9664\u4f4e\u6548\u7ec4\u4ef6\uff08\u67e5\u8be2\u7f13\u5b58\uff09\u3001\u589e\u5f3a\u5b89\u5168\u6027\uff08\u8ba4\u8bc1\u63d2\u4ef6\uff09\u3001\u4f18\u5316\u6027\u80fd\uff08\u4f18\u5316\u5668\u3001\u65e5\u5fd7\uff09\u3001\u7b80\u5316\u7ef4\u62a4\uff08\u52a8\u6001\u6743\u9650\u3001undo \u56de\u6536\uff09\u7b49\u3002<\/p>\n<div style=\"height:1.5em\"><\/div>\n<h1>03. \u5b58\u50a8\u5f15\u64ce<\/h1>\n<p>MySQL \u7684\u5b58\u50a8\u5f15\u64ce\u662f\u8d1f\u8d23\u6570\u636e\u5b58\u50a8\u3001\u8bfb\u53d6\u53ca\u5e95\u5c42\u7279\u6027\u5b9e\u73b0\u7684\u6838\u5fc3\u6a21\u5757\uff0c\u91c7\u7528 \u201c\u63d2\u4ef6\u5f0f\u201d \u8bbe\u8ba1\uff0c\u4e0d\u540c\u5f15\u64ce\u652f\u6301\u7684\u529f\u80fd\uff08\u5982\u4e8b\u52a1\u3001\u9501\u673a\u5236\uff09\u5dee\u5f02\u663e\u8457\u3002<\/p>\n<div style=\"height:1em\"><\/div>\n<h2>1. InnoDB\uff08\u9ed8\u8ba4\uff09<\/h2>\n<p>InnoDB \u662f MySQL \u6700\u5e38\u7528\uff08\u9ed8\u8ba4\uff09\u7684\u5b58\u50a8\u5f15\u64ce\uff0c\u4ee5\u4e8b\u52a1\u652f\u6301\u3001\u9ad8\u5e76\u53d1\u4e3a\u6838\u5fc3\u4f18\u52bf\uff0c5.7 \u548c 8.0 \u5747\u5c06\u5176\u4f5c\u4e3a\u9ed8\u8ba4\u5f15\u64ce\uff0c\u7248\u672c\u95f4\u4f18\u5316\u96c6\u4e2d\u5728\u6027\u80fd\u3001\u53ef\u9760\u6027\u548c\u529f\u80fd\u6269\u5c55\u3002<\/p>\n<p><strong>\u6838\u5fc3\u901a\u7528\u7279\u6027\uff085.7 \u548c 8.0 \u5171\u901a\uff09<\/strong><\/p>\n<ul>\n<li>\u652f\u6301\u4e8b\u52a1\uff08ACID \u7279\u6027\uff09\uff1a\u901a\u8fc7 redo log\uff08\u4fdd\u8bc1\u6301\u4e45\u6027\uff09\u3001undo log\uff08\u4fdd\u8bc1\u539f\u5b50\u6027\u548c\u9694\u79bb\u6027\uff09\u5b9e\u73b0\u3002<\/li>\n<li>\u884c\u7ea7\u9501\uff1a\u4ec5\u9501\u5b9a\u4fee\u6539\u7684\u884c\uff08\u800c\u975e\u5168\u8868\uff09\uff0c\u9002\u5408\u9ad8\u5e76\u53d1\u5199\u573a\u666f\uff08\u5982\u7535\u5546\u8ba2\u5355\u66f4\u65b0\uff09\u3002<\/li>\n<li>\u805a\u7c07\u7d22\u5f15\uff1a\u6570\u636e\u4e0e\u4e3b\u952e\u7d22\u5f15\u7269\u7406\u5b58\u50a8\u5728\u4e00\u8d77\uff0c\u67e5\u8be2\u4e3b\u952e\u65f6\u6548\u7387\u6781\u9ad8\u3002<\/li>\n<li>\u5916\u952e\u7ea6\u675f\uff1a\u652f\u6301\u8868\u95f4\u5916\u952e\u5173\u8054\uff08\u5982orders\u8868\u5173\u8054users\u8868\u7684user_id\uff09\u3002<\/li>\n<\/ul>\n<p><strong>5.7 \u7248\u672c InnoDB \u7279\u6027<\/strong><\/p>\n<ul>\n<li>\u81ea\u589e ID\uff08AUTO_INCREMENT\uff09\uff1a\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u91cd\u542f MySQL \u540e\u53ef\u80fd\u56e0\u672a\u6301\u4e45\u5316\u5bfc\u81f4\u91cd\u590d\uff08\u9700\u4f9d\u8d56 binlog \u6062\u590d\uff0c\u4f46\u5b58\u5728\u98ce\u9669\uff09\u3002<\/li>\n<li>\u7d22\u5f15\u9650\u5236\uff1a\u4ec5\u8bed\u6cd5\u652f\u6301\u964d\u5e8f\u7d22\u5f15\uff08DESC\uff09\uff0c\u5b9e\u9645\u4ecd\u6309\u5347\u5e8f\u5b58\u50a8\uff0c\u67e5\u8be2\u964d\u5e8f\u6570\u636e\u65f6\u9700\u989d\u5916\u6392\u5e8f\u3002<\/li>\n<li>\u9501\u673a\u5236\uff1a\u95f4\u9699\u9501\uff08Gap Lock\uff09\u8303\u56f4\u8f83\u5bbd\u6cdb\uff0c\u53ef\u80fd\u5bfc\u81f4\u9ad8\u5e76\u53d1\u4e0b\u9501\u51b2\u7a81\u589e\u52a0\uff08\u5982\u6279\u91cf\u63d2\u5165\u76f8\u90bb ID \u65f6\uff09\u3002<\/li>\n<li>undo log\uff1a\u9ed8\u8ba4\u968f\u8868\u7a7a\u95f4\u5b58\u50a8\uff0c\u957f\u671f\u8fd0\u884c\u540e\u53ef\u80fd\u56e0\u672a\u81ea\u52a8\u56de\u6536\u5bfc\u81f4\u78c1\u76d8\u7a7a\u95f4\u81a8\u80c0\uff08\u9700\u624b\u52a8\u6e05\u7406\uff09\u3002<\/li>\n<\/ul>\n<p><strong>8.0 \u7248\u672c InnoDB \u5173\u952e\u6539\u8fdb<\/strong><\/p>\n<ul>\n<li>\u81ea\u589e ID \u6301\u4e45\u5316\uff1a\u5c06\u81ea\u589e ID \u5199\u5165 redo log\uff0c\u91cd\u542f\u540e\u53ef\u901a\u8fc7\u65e5\u5fd7\u6062\u590d\uff0c\u5f7b\u5e95\u89e3\u51b3 5.7 \u7684\u91cd\u590d\u95ee\u9898\u3002<\/li>\n<li>\u7d22\u5f15\u589e\u5f3a\uff1a\n<ul>\n<li>\u771f\u6b63\u652f\u6301\u964d\u5e8f\u7d22\u5f15\uff08DESC\uff09\uff0c\u67e5\u8be2\u964d\u5e8f\u6392\u5e8f\u6570\u636e\u65f6\u65e0\u9700\u989d\u5916\u6392\u5e8f\uff0c\u76f4\u63a5\u4f7f\u7528\u7d22\u5f15\u3002<\/li>\n<li>\u65b0\u589e \u201c\u9690\u85cf\u7d22\u5f15\u201d\uff08INVISIBLE\uff09\uff1a\u53ef\u6807\u8bb0\u7d22\u5f15\u4e3a\u9690\u85cf\uff08\u4e0d\u5f71\u54cd\u7269\u7406\u5b58\u50a8\uff09\uff0c\u7528\u4e8e\u4e34\u65f6\u7981\u7528\u7d22\u5f15\u6d4b\u8bd5\u6027\u80fd\uff08\u65e0\u9700\u5220\u9664\u91cd\u5efa\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li>\u9501\u4f18\u5316\uff1a\u95f4\u9699\u9501\u8303\u56f4\u66f4\u7cbe\u51c6\uff0c\u51cf\u5c11\u975e\u5fc5\u8981\u9501\u5b9a\uff08\u5982\u6279\u91cf\u63d2\u5165\u65f6\u4ec5\u9501\u5b9a\u5b9e\u9645\u9700\u8981\u7684\u533a\u95f4\uff09\uff0c\u964d\u4f4e\u9501\u51b2\u7a81\u3002<\/li>\n<li>undo log \u81ea\u52a8\u56de\u6536\uff1a\u652f\u6301innodb_undo_log_truncate\u53c2\u6570\uff08\u9ed8\u8ba4\u5f00\u542f\uff09\uff0c\u81ea\u52a8\u6536\u7f29\u8fc7\u5927\u7684 undo log\uff0c\u51cf\u5c11\u4eba\u5de5\u7ef4\u62a4\u6210\u672c\u3002<\/li>\n<li>\u8868\u7a7a\u95f4\u52a0\u5bc6\uff1a\u652f\u6301\u900f\u660e\u6570\u636e\u52a0\u5bc6\uff08TDE\uff09\uff0c\u8868\u7a7a\u95f4\u6587\u4ef6\uff08.ibd\uff09\u52a0\u5bc6\u5b58\u50a8\uff0c\u63d0\u5347\u6570\u636e\u5b89\u5168\u6027\u3002<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>2. MyISAM<\/h2>\n<p>MyISAM \u662f\u65e9\u671f MySQL \u7684\u9ed8\u8ba4\u5f15\u64ce\uff0c\u56e0\u4e0d\u652f\u6301\u4e8b\u52a1\u548c\u884c\u9501\uff0c\u9010\u6e10\u88ab InnoDB \u66ff\u4ee3\uff0c5.7 \u548c 8.0 \u4e2d\u4ecd\u4fdd\u7559\u4f46\u5e94\u7528\u573a\u666f\u6709\u9650\u3002<\/p>\n<p><strong>\u6838\u5fc3\u901a\u7528\u7279\u6027\uff085.7 \u548c 8.0 \u5171\u901a\uff09<\/strong><\/p>\n<ul>\n<li>\u4e0d\u652f\u6301\u4e8b\u52a1\u548c\u5916\u952e\uff1a\u4ec5\u9002\u5408\u65e0\u9700\u4e8b\u52a1\u4fdd\u8bc1\u7684\u573a\u666f\u3002<\/li>\n<li>\u8868\u7ea7\u9501\uff1a\u5199\u64cd\u4f5c\uff08\u589e\u5220\u6539\uff09\u4f1a\u9501\u5b9a\u5168\u8868\uff0c\u8bfb\u64cd\u4f5c\u9700\u7b49\u5f85\u5199\u9501\u91ca\u653e\uff0c\u5e76\u53d1\u5199\u6027\u80fd\u5dee\u3002<\/li>\n<li>\u72ec\u7acb\u6587\u4ef6\u5b58\u50a8\uff1a\u6570\u636e\u5b58\u4e8e.MYD\u6587\u4ef6\uff0c\u7d22\u5f15\u5b58\u4e8e.MYI\u6587\u4ef6\uff0c\u53ef\u76f4\u63a5\u590d\u5236\u6587\u4ef6\u8fc1\u79fb\u8868\u3002<\/li>\n<\/ul>\n<p><strong>5.7 \u7248\u672c\uff1a<\/strong>\u4ecd\u6709\u90e8\u5206\u573a\u666f\u4f7f\u7528\uff08\u5982\u53ea\u8bfb\u65e5\u5fd7\u8868\uff09\uff0c\u4f46\u5df2\u660e\u786e\u4e0d\u63a8\u8350\u7528\u4e8e\u6838\u5fc3\u4e1a\u52a1\u3002<br \/>\n<strong>8.0 \u7248\u672c\uff1a<\/strong>\u8fdb\u4e00\u6b65\u5f31\u5316 MyISAM\uff0c\u9ed8\u8ba4\u914d\u7f6e\u4e0b\u6027\u80fd\u4f18\u5316\u503e\u5411 InnoDB\uff0c\u4e14\u79fb\u9664\u4e86\u90e8\u5206\u5bf9 MyISAM \u7684\u5197\u4f59\u652f\u6301\uff08\u5982\u5168\u6587\u7d22\u5f15\u7684\u90e8\u5206\u4f18\u5316\u4ec5\u9488\u5bf9 InnoDB\uff09\u3002<\/p>\n<div style=\"height:1em\"><\/div>\n<h2>3. Memory<\/h2>\n<p>\u5185\u5b58\u5f15\u64ce<br \/>\n\u6570\u636e\u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0c\u9002\u5408\u4e34\u65f6\u6570\u636e\u5904\u7406\uff0c\u6027\u80fd\u6781\u5feb\u4f46\u6570\u636e\u6613\u5931\uff08\u91cd\u542f\u4e22\u5931\uff09\u3002<\/p>\n<p><strong>5.7 \u7248\u672c\u7279\u6027<\/strong><\/p>\n<ul>\n<li>\u652f\u6301\u54c8\u5e0c\u7d22\u5f15\uff08\u9ed8\u8ba4\uff09\u548c B + \u6811\u7d22\u5f15\uff0c\u54c8\u5e0c\u7d22\u5f15\u9002\u5408\u7b49\u503c\u67e5\u8be2\uff08=\uff09\uff0c\u4e0d\u652f\u6301\u8303\u56f4\u67e5\u8be2\uff08&gt;\u3001&lt;\uff09\u3002<\/li>\n<li>\u8868\u5927\u5c0f\u53d7<code>max_heap_table_size<\/code>\u9650\u5236\uff08\u9ed8\u8ba4 16MB\uff09\uff0c\u8d85\u51fa\u540e\u4f1a\u62a5\u9519\u3002<\/li>\n<\/ul>\n<p><strong>8.0 \u7248\u672c\u6539\u8fdb<\/strong><\/p>\n<ul>\n<li>\u4f18\u5316\u5185\u5b58\u5206\u914d\u673a\u5236\uff0c\u51cf\u5c11\u5c0f\u8868\u7684\u5185\u5b58\u6d6a\u8d39\u3002<\/li>\n<li>\u652f\u6301\u52a8\u6001\u8c03\u6574<code>max_heap_table_size<\/code>\uff08\u65e0\u9700\u91cd\u5efa\u8868\uff09\uff0c\u66f4\u7075\u6d3b\u9002\u914d\u4e34\u65f6\u6570\u636e\u5927\u5c0f\u3002<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>4. CSV<\/h2>\n<p>\u9017\u53f7\u5206\u5272\u503c\u5f15\u64ce<br \/>\n\u6570\u636e\u4ee5 CSV \u683c\u5f0f\u6587\u4ef6\u5b58\u50a8\uff08<code>.csv<\/code>\uff09\uff0c\u9002\u5408\u6570\u636e\u4ea4\u6362\uff08\u5982\u4e0e Excel\u3001\u6587\u672c\u6587\u4ef6\u4ea4\u4e92\uff09\u3002<\/p>\n<p><strong>5.7 \u7248\u672c\u7279\u6027<\/strong><\/p>\n<ul>\n<li>\u8868\u7ed3\u6784\u5b58\u4e8e<code>.frm<\/code>\u6587\u4ef6\uff0c\u6570\u636e\u5b58\u4e8e<code>.csv<\/code>\u6587\u4ef6\uff0c\u53ef\u76f4\u63a5\u7528\u6587\u672c\u7f16\u8f91\u5668\u67e5\u770b \/ \u4fee\u6539\u3002<\/li>\n<li>\u4e0d\u652f\u6301\u7d22\u5f15\u548c\u4e8b\u52a1\uff0c\u4ec5\u9002\u5408\u7b80\u5355\u7684\u5bfc\u5165\u5bfc\u51fa\u573a\u666f\u3002<\/li>\n<\/ul>\n<p><strong>8.0 \u7248\u672c\u6539\u8fdb<\/strong><\/p>\n<ul>\n<li>\u589e\u5f3a\u517c\u5bb9\u6027\uff1a\u652f\u6301 CSV \u6587\u4ef6\u4e2d\u5305\u542b\u6362\u884c\u7b26\uff08\u9700\u7279\u6b8a\u5904\u7406\uff09\uff0c\u51cf\u5c11\u5bfc\u5165\u5bfc\u51fa\u65f6\u7684\u683c\u5f0f\u9519\u8bef\u3002<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>5. \u603b\u7ed3<\/h2>\n<ul>\n<li><strong>InnoDB\uff1a<\/strong>5.7 \u5df2\u5177\u5907\u4e8b\u52a1\u3001\u884c\u9501\u6838\u5fc3\u80fd\u529b\uff0c8.0 \u901a\u8fc7\u81ea\u589e ID \u6301\u4e45\u5316\u3001\u7d22\u5f15\u4f18\u5316\u3001\u9501\u7ec6\u5316\u7b49\u63d0\u5347\u53ef\u9760\u6027\u548c\u6027\u80fd\uff0c\u662f\u6240\u6709\u4e1a\u52a1\u7684\u9996\u9009\u3002<\/li>\n<li><strong>MyISAM\uff1a<\/strong>\u4ec5\u9002\u5408\u53ea\u8bfb\u3001\u4f4e\u5e76\u53d1\u573a\u666f\uff0c8.0 \u4e2d\u8fdb\u4e00\u6b65\u88ab\u8fb9\u7f18\u5316\u3002<\/li>\n<li><strong>Memory\/CSV\uff1a<\/strong>\u4f5c\u4e3a\u8f85\u52a9\u5f15\u64ce\uff0c8.0 \u4e3b\u8981\u4f18\u5316\u4e86\u6613\u7528\u6027\uff08\u5982\u52a8\u6001\u8c03\u6574\u5185\u5b58\u8868\u5927\u5c0f\uff09\uff0c\u6838\u5fc3\u529f\u80fd\u65e0\u672c\u8d28\u53d8\u5316\u3002<\/li>\n<\/ul>\n<div style=\"height:1.5em\"><\/div>\n<h1>04. InnoDB\u5b58\u50a8\u5f15\u64ce<\/h1>\n<p>InnoDB\u4f5c\u4e3aMySQL\u7684\u9ed8\u8ba4\u4e14\u5e38\u7528\u7684\u641c\u7d22\u5f15\u64ce\uff0c\u6709\u5982\u4e0b\u7684\u6838\u5fc3\u7279\u6027\uff1a<\/p>\n<div style=\"height:0.7em\"><\/div>\n<p><strong>1. \u4e8b\u52a1\u652f\u6301\uff08ACID\uff09<\/strong><\/p>\n<ul>\n<li>\u5b8c\u5168\u652f\u6301\u4e8b\u52a1\u7684\u539f\u5b50\u6027\uff08A\uff09\u3001\u4e00\u81f4\u6027\uff08C\uff09\u3001\u9694\u79bb\u6027\uff08I\uff09\u3001\u6301\u4e45\u6027\uff08D\uff09\u3002<\/li>\n<\/ul>\n<div style=\"height:0.7em\"><\/div>\n<p><strong>2. \u9501\u673a\u5236<\/strong><\/p>\n<ul>\n<li>\u652f\u6301\u884c\u7ea7\u9501 + \u95f4\u9699\u9501\uff08Next-Key Lock\uff09\uff0c\u884c\u7ea7\u9501\u4ec5\u9501\u5b9a\u4fee\u6539\u884c\uff08\u9ad8\u5e76\u53d1\u53cb\u597d\uff09\uff0c\u95f4\u9699\u9501\u9632\u6b62\u5e7b\u8bfb\u3002<\/li>\n<li><strong>8.0 \u53d8\u5316\uff1a<\/strong>\u95f4\u9699\u9501\u8303\u56f4\u66f4\u7cbe\u51c6\uff0c\u51cf\u5c11\u975e\u5fc5\u8981\u9501\u5b9a\uff08\u5982\u6279\u91cf\u63d2\u5165\u76f8\u90bb ID \u65f6\u4ec5\u9501\u5b9e\u9645\u533a\u95f4\uff09\uff0c\u964d\u4f4e\u9501\u51b2\u7a81\u6982\u7387\u3002<\/li>\n<\/ul>\n<div style=\"height:0.7em\"><\/div>\n<p><strong>3. \u805a\u7c07\u7d22\u5f15<\/strong><\/p>\n<ul>\n<li>\u6570\u636e\u4e0e\u4e3b\u952e\u7d22\u5f15\u7269\u7406\u5b58\u50a8\u5728\u4e00\u8d77\uff0c\u5f62\u6210 B + \u6811\u7ed3\u6784\uff0c\u4e3b\u952e\u67e5\u8be2\u53ef\u76f4\u63a5\u83b7\u53d6\u6570\u636e\u3002<\/li>\n<\/ul>\n<div style=\"height:0.7em\"><\/div>\n<p><strong>4. \u81ea\u589e ID\uff08AUTO_INCREMENT\uff09<\/strong><\/p>\n<ul>\n<li>\u81ea\u589e ID \u5b58\u50a8\u5728\u5185\u5b58\u4e2d\uff0cMySQL \u91cd\u542f\u540e\u53ef\u80fd\u56e0\u672a\u6301\u4e45\u5316\u5bfc\u81f4\u5e8f\u5217\u91cd\u590d\uff08\u9700\u4f9d\u8d56 binlog \u90e8\u5206\u6062\u590d\uff09\u3002<\/li>\n<li><strong>8.0 \u53d8\u5316\uff1a<\/strong>\u81ea\u589e ID \u5199\u5165 redo log \u6301\u4e45\u5316\uff0c\u91cd\u542f\u540e\u53ef\u901a\u8fc7\u65e5\u5fd7\u6062\u590d\u5e8f\u5217\uff0c\u5f7b\u5e95\u89e3\u51b3\u91cd\u590d\u95ee\u9898\u3002<\/li>\n<\/ul>\n<div style=\"height:0.7em\"><\/div>\n<p><strong>5. \u7d22\u5f15\u7279\u6027<\/strong><\/p>\n<ul>\n<li>\u652f\u6301 B + \u6811\u7d22\u5f15\uff08\u9ed8\u8ba4\uff09\u3001\u5168\u6587\u7d22\u5f15\u3001\u524d\u7f00\u7d22\u5f15\uff1b\u4ec5\u8bed\u6cd5\u652f\u6301\u964d\u5e8f\u7d22\u5f15\uff08<code>DESC<\/code>\uff09\uff0c\u5b9e\u9645\u4ecd\u6309\u5347\u5e8f\u5b58\u50a8\u3002<\/li>\n<li><strong>8.0 \u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>\u771f\u6b63\u652f\u6301\u964d\u5e8f\u7d22\u5f15\uff0c\u67e5\u8be2\u964d\u5e8f\u6392\u5e8f\u6570\u636e\u65f6\u65e0\u9700\u989d\u5916\u6392\u5e8f\uff0c\u76f4\u63a5\u590d\u7528\u7d22\u5f15\u3002<\/li>\n<li>\u65b0\u589e\u9690\u85cf\u7d22\u5f15\uff08<code>INVISIBLE<\/code>\uff09\uff0c\u53ef\u4e34\u65f6\u7981\u7528\u7d22\u5f15\uff08\u4e0d\u5220\u9664\uff09\uff0c\u65b9\u4fbf\u6d4b\u8bd5\u7d22\u5f15\u6027\u80fd\u5f71\u54cd\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:0.7em\"><\/div>\n<p><strong>6. \u65e5\u5fd7\u4f9d\u8d56\uff08redo log\/undo log\uff09<\/strong><\/p>\n<ul>\n<li>redo log\uff1a\u5faa\u73af\u5199\u7684\u7269\u7406\u65e5\u5fd7\uff0c\u8bb0\u5f55\u6570\u636e\u9875\u4fee\u6539\uff0c\u4fdd\u8bc1\u5d29\u6e83\u6062\u590d\u3002<\/li>\n<li>undo log\uff1a\u8bb0\u5f55\u6570\u636e\u4fee\u6539\u524d\u7684\u72b6\u6001\uff0c\u7528\u4e8e\u4e8b\u52a1\u56de\u6eda\u548c MVCC\uff08\u591a\u7248\u672c\u5e76\u53d1\u63a7\u5236\uff09\uff0c\u9ed8\u8ba4\u968f\u8868\u7a7a\u95f4\u5b58\u50a8\uff0c\u6613\u81a8\u80c0\u9700\u624b\u52a8\u6e05\u7406\u3002<\/li>\n<li><strong>8.0 \u53d8\u5316\uff1a<\/strong>\n<ul>\n<li>redo log \u9ed8\u8ba4\u5355\u4e2a\u6587\u4ef6\u5927\u5c0f\u4ece 48MB \u589e\u81f3 1GB\uff0c\u51cf\u5c11\u65e5\u5fd7\u5207\u6362\u5f00\u9500\u3002<\/li>\n<li>undo log \u652f\u6301\u81ea\u52a8\u56de\u6536\uff08<code>innodb_undo_log_truncate<\/code>\u9ed8\u8ba4\u5f00\u542f\uff09\uff0c\u65e0\u9700\u624b\u52a8\u6e05\u7406\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:0.7em\"><\/div>\n<p><strong>7. \u5916\u952e\u7ea6\u675f<\/strong><\/p>\n<ul>\n<li>\u652f\u6301\u8868\u95f4\u5916\u952e\u5173\u8054\uff08\u5982\uff1a<code>orders.user_id<\/code>\u5173\u8054<code>users.id<\/code>\uff09\uff0c\u4fdd\u8bc1\u6570\u636e\u5f15\u7528\u5b8c\u6574\u6027\u3002<\/li>\n<\/ul>\n<div style=\"height:0.7em\"><\/div>\n<p><strong>8. \u5b89\u5168\u6027\u589e\u5f3a<\/strong><\/p>\n<ul>\n<li>\u65e0\u8868\u7a7a\u95f4\u52a0\u5bc6\u529f\u80fd\uff0c\u6570\u636e\u6587\u4ef6\uff08<code>.ib<\/code>d\uff09\u4ee5\u660e\u6587\u5b58\u50a8\u3002<\/li>\n<li><strong>8.0 \u53d8\u5316\uff1a<\/strong>\u65b0\u589e\u900f\u660e\u6570\u636e\u52a0\u5bc6\uff08TDE\uff09\uff0c\u652f\u6301\u8868\u7a7a\u95f4\u6587\u4ef6\u52a0\u5bc6\u5b58\u50a8\uff0c\u63d0\u5347\u654f\u611f\u6570\u636e\u5b89\u5168\u6027\uff08\u5982\u7528\u6237\u5bc6\u7801\u3001\u652f\u4ed8\u4fe1\u606f\u8868\uff09\u3002<\/li>\n<\/ul>\n<div style=\"height:1.5em\"><\/div>\n<h1>05. \u4e09\u5927\u8303\u5f0f\u548c\u53cd\u8303\u5f0f<\/h1>\n<p>MySQL \u7684\u4e09\u5927\u8303\u5f0f\uff081NF\u30012NF\u30013NF\uff09\u662f\u5173\u7cfb\u578b\u6570\u636e\u5e93\u8bbe\u8ba1\u7684\u57fa\u7840\u539f\u5219\uff0c\u76ee\u7684\u662f<strong>\u51cf\u5c11\u6570\u636e\u5197\u4f59\u3001\u4fdd\u8bc1\u6570\u636e\u4e00\u81f4\u6027\u3001\u907f\u514d\u63d2\u5165 \/ \u66f4\u65b0 \/ \u5220\u9664\u5f02\u5e38<\/strong>\uff1b<br \/>\n\u53cd\u8303\u5f0f\u662f\u6709\u610f\u6253\u7834\u8303\u5f0f\u89c4\u5219\uff0c\u6709\u7b56\u7565\u5730\u4fdd\u7559\u9002\u91cf\u5197\u4f59\uff0c\u76ee\u7684\u662f\u51cf\u5c11\u591a\u8868 <code>JOIN<\/code>\uff0c<strong>\u63d0\u5347\u67e5\u8be2\u6548\u7387<\/strong>\uff08\u5c24\u5176\u8bfb\u591a\u5199\u5c11\u573a\u666f\uff09\u3002<\/p>\n<div style=\"height:1em\"><\/div>\n<h2>1. \u7b2c\u4e00\u8303\u5f0f\uff081NF\uff09<\/h2>\n<p>\u7b2c\u4e00\u8303\u5f0f\uff081NF\uff09\uff1a<strong>\u5b57\u6bb5\u539f\u5b50\u5316\uff0c\u4e0d\u53ef\u518d\u5206\u3002<\/strong><\/p>\n<ul>\n<li><strong>\u6838\u5fc3\u8981\u6c42\uff1a<\/strong>\u8868\u4e2d\u6240\u6709\u5b57\u6bb5\u7684\u503c\u5fc5\u987b\u662f \u201c\u539f\u5b50\u6027\u201d \u7684\uff08\u4e0d\u53ef\u518d\u62c6\u5206\u4e3a\u66f4\u5c0f\u7684\u6570\u636e\u5355\u5143\uff09\u3002<\/li>\n<li><strong>\u76ee\u7684\uff1a<\/strong>\u907f\u514d\u540c\u4e00\u5b57\u6bb5\u5b58\u50a8\u591a\u7ef4\u5ea6\u4fe1\u606f\uff0c\u5bfc\u81f4\u67e5\u8be2\u548c\u4fee\u6539\u6df7\u4e71\u3002<\/li>\n<li><strong>\u4f8b\u5b50\uff1a<\/strong>\n<ul>\n<li>\u53cd\u4f8b\uff1a\u7528\u6237\u8868\u7684<code>address<\/code>\u5b57\u6bb5\u5b58\u50a8 \u201c\u4e2d\u56fd &#8211; \u5317\u4eac &#8211; \u671d\u9633\u533a\u201d\uff08\u53ef\u62c6\u5206\u4e3a<code>country<\/code>\u3001<code>city<\/code>\u3001<code>district<\/code>\uff09\uff1b<\/li>\n<li>\u6b63\u4f8b\uff1a\u62c6\u5206\u4e3a<code>country<\/code>\u3001<code>city<\/code>\u3001<code>district<\/code>\u4e09\u4e2a\u5b57\u6bb5\uff0c\u6bcf\u4e2a\u5b57\u6bb5\u4e0d\u53ef\u518d\u5206\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5b9e\u8df5\uff1a<\/strong>1NF \u662f\u57fa\u7840\uff0c\u51e0\u4e4e\u6240\u6709\u4e1a\u52a1\u8868\u90fd\u9700\u6ee1\u8db3\uff08\u5982\uff1a\u8ba2\u5355\u8868\u7684<code>phone<\/code>\u5b57\u6bb5\u4e0d\u5b58\u50a8 \u201c\u56fa\u8bdd + \u624b\u673a\u201d\uff0c\u800c\u662f\u5355\u72ec\u5b57\u6bb5\uff09\u3002<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>2. \u7b2c\u4e8c\u8303\u5f0f\uff082NF\uff09<\/h2>\n<p>\u7b2c\u4e8c\u8303\u5f0f\uff082NF\uff09\uff1a<strong>\u6d88\u9664 \u201c\u90e8\u5206\u4f9d\u8d56\u201d\uff0c\u975e\u4e3b\u5c5e\u6027\u5b8c\u5168\u4f9d\u8d56\u4e3b\u952e\u3002<\/strong><\/p>\n<ul>\n<li><strong>\u6838\u5fc3\u8981\u6c42\uff1a<\/strong>\u5728 1NF \u57fa\u7840\u4e0a\uff0c\u8868\u7684\u4e3b\u952e\u5fc5\u987b\u662f \u201c\u8054\u5408\u4e3b\u952e\u201d\uff08\u591a\u5b57\u6bb5\u7ec4\u6210\uff09\uff0c\u4e14\u6240\u6709\u975e\u4e3b\u5c5e\u6027\u5fc5\u987b\u5b8c\u5168\u4f9d\u8d56\u4e8e\u6574\u4e2a\u4e3b\u952e\uff0c\u4e0d\u80fd\u4ec5\u4f9d\u8d56\u4e3b\u952e\u7684\u4e00\u90e8\u5206\uff08\u5373\u6d88\u9664 \u201c\u90e8\u5206\u4f9d\u8d56\u201d\uff09\u3002<\/li>\n<li><strong>\u76ee\u7684\uff1a<\/strong>\u907f\u514d\u56e0\u4e3b\u952e\u90e8\u5206\u5b57\u6bb5\u53d8\u5316\u5bfc\u81f4\u7684\u6570\u636e\u5f02\u5e38\uff08\u5982\u4fee\u6539\u90e8\u5206\u4e3b\u952e\u540e\uff0c\u975e\u4e3b\u5c5e\u6027\u9700\u8054\u52a8\u66f4\u65b0\uff09\u3002<\/li>\n<li><strong>\u4f8b\u5b50\uff1a<\/strong>\n<ul>\n<li>\u53cd\u4f8b\uff1a\u8ba2\u5355\u9879\u8868\uff08\u8054\u5408\u4e3b\u952e<code>order_id+product_id<\/code>\uff09\u4e2d\uff0c<code>product_name<\/code>\u4ec5\u4f9d\u8d56<code>product_id<\/code>\uff08\u4e3b\u952e\u7684\u4e00\u90e8\u5206\uff09\uff0c\u5c5e\u4e8e\u90e8\u5206\u4f9d\u8d56\uff1b<\/li>\n<li>\u6b63\u4f8b\uff1a<code>product_name<\/code>\u5e94\u5b58\u50a8\u5728\u4ea7\u54c1\u8868\u4e2d\uff0c\u8ba2\u5355\u9879\u8868\u53ea\u5b58<code>product_id<\/code>\uff0c\u901a\u8fc7\u5173\u8054\u4ea7\u54c1\u8868\u83b7\u53d6\u540d\u79f0\uff08\u975e\u4e3b\u5c5e\u6027<code>quantity<\/code>\u3001<code>price<\/code>\u5b8c\u5168\u4f9d\u8d56<code>order_id+product_id<\/code>\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5b9e\u8df5\uff1a<\/strong>\u591a\u5bf9\u591a\u5173\u7cfb\u7684\u4e2d\u95f4\u8868\uff08\u5982 \u201c\u7528\u6237 &#8211; \u89d2\u8272\u201d \u5173\u8054\u8868\uff09\u9700\u6ee1\u8db3 2NF\uff0c\u907f\u514d\u5197\u4f59\u5b58\u50a8\u89d2\u8272\u540d\u79f0\u7b49\u4fe1\u606f\u3002<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>3. \u7b2c\u4e09\u8303\u5f0f\uff083NF\uff09<\/h2>\n<p>\u7b2c\u4e09\u8303\u5f0f\uff083NF\uff09\uff1a<strong>\u6d88\u9664 \u201c\u4f20\u9012\u4f9d\u8d56\u201d\uff0c\u975e\u4e3b\u5c5e\u6027\u4e0d\u4f9d\u8d56\u5176\u4ed6\u975e\u4e3b\u5c5e\u6027\u3002<\/strong><\/p>\n<ul>\n<li><strong>\u6838\u5fc3\u8981\u6c42\uff1a<\/strong>\u5728 2NF \u57fa\u7840\u4e0a\uff0c\u6240\u6709\u975e\u4e3b\u5c5e\u6027\u5fc5\u987b\u76f4\u63a5\u4f9d\u8d56\u4e8e\u4e3b\u952e\uff0c\u4e0d\u80fd\u4f9d\u8d56\u4e8e\u5176\u4ed6\u975e\u4e3b\u5c5e\u6027\uff08\u5373\u6d88\u9664 \u201c\u4f20\u9012\u4f9d\u8d56\u201d\uff09\u3002<\/li>\n<li><strong>\u76ee\u7684\uff1a<\/strong>\u907f\u514d\u56e0\u67d0\u4e2a\u975e\u4e3b\u5c5e\u6027\u53d8\u5316\uff0c\u5bfc\u81f4\u5176\u4ed6\u975e\u4e3b\u5c5e\u6027\u9700\u8054\u52a8\u66f4\u65b0\uff08\u5982 A \u4f9d\u8d56\u4e3b\u952e\uff0cB \u4f9d\u8d56 A\uff0c\u5219 B \u4f20\u9012\u4f9d\u8d56\u4e3b\u952e\uff09\u3002<\/li>\n<li><strong>\u4f8b\u5b50\uff1a<\/strong>\n<ul>\n<li>\u53cd\u4f8b\uff1a\u7528\u6237\u8868\uff08\u4e3b\u952e<code>user_id<\/code>\uff09\u4e2d\uff0c<code>area_name<\/code>\u4f9d\u8d56<code>area_id<\/code>\uff0c<code>area_id<\/code>\u4f9d\u8d56<code>user_id<\/code>\uff0c\u5219<code>area_name<\/code>\u4f20\u9012\u4f9d\u8d56<code>user_id<\/code>\uff1b<\/li>\n<li>\u6b63\u4f8b\uff1a<code>area_name<\/code>\u5e94\u5b58\u50a8\u5728\u533a\u57df\u8868\u4e2d\uff0c\u7528\u6237\u8868\u53ea\u5b58<code>area_id<\/code>\uff0c\u901a\u8fc7\u5173\u8054\u533a\u57df\u8868\u83b7\u53d6\u540d\u79f0\uff08\u975e\u4e3b\u5c5e\u6027\u4ec5\u76f4\u63a5\u4f9d\u8d56<code>user_id<\/code>\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u5b9e\u8df5\uff1a<\/strong>\u7528\u6237\u8868\u3001\u5546\u54c1\u8868\u7b49\u6838\u5fc3\u8868\u9700\u6ee1\u8db3 3NF\uff0c\u907f\u514d\u5b58\u50a8 \u201c\u90e8\u95e8\u540d\u79f0\u201d\u201c\u5206\u7c7b\u540d\u79f0\u201d \u7b49\u53ef\u901a\u8fc7\u5173\u8054\u83b7\u53d6\u7684\u5b57\u6bb5\u3002<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>4. \u53cd\u8303\u5f0f<\/h2>\n<p>\u53cd\u8303\u5f0f\u662f\u6709\u610f\u6253\u7834\u8303\u5f0f\u89c4\u5219\uff0c\u6709\u7b56\u7565\u5730\u4fdd\u7559\u9002\u91cf\u5197\u4f59\uff0c\u76ee\u7684\u662f\u51cf\u5c11\u591a\u8868 <code>JOIN<\/code>\uff0c<strong>\u63d0\u5347\u67e5\u8be2\u6548\u7387<\/strong>\uff08\u5c24\u5176\u8bfb\u591a\u5199\u5c11\u573a\u666f\uff09\u3002<\/p>\n<ul>\n<li><strong>\u6838\u5fc3\u601d\u8def<\/strong><br \/>\n\u901a\u8fc7\u5728\u8868\u4e2d\u5197\u4f59\u5b58\u50a8\u5176\u4ed6\u8868\u7684\u5b57\u6bb5\uff0c\u907f\u514d\u67e5\u8be2\u65f6\u5173\u8054\u591a\u4e2a\u8868\uff08<code>JOIN<\/code> \u64cd\u4f5c\u8017\u65f6\uff0c\u5c24\u5176\u5927\u6570\u636e\u91cf\u65f6\uff09\u3002<\/li>\n<li><strong>\u4f8b\u5b50\uff1a<\/strong>\n<ul>\n<li>\u7535\u5546\u5546\u54c1\u5217\u8868\u9875\u9700\u5c55\u793a \u201c\u5546\u54c1\u540d\u79f0 + \u5206\u7c7b\u540d\u79f0\u201d\uff0c\u82e5\u4e25\u683c\u9075\u5faa 3NF\uff0c\u9700\u5173\u8054<code>product<\/code>\u8868\u548c<code>category<\/code>\u8868\uff1b<\/li>\n<li>\u53cd\u8303\u5f0f\u4f18\u5316\uff1a\u5728<code>product<\/code>\u8868\u4e2d\u5197\u4f59<code>category_name<\/code>\u5b57\u6bb5\uff0c\u67e5\u8be2\u65f6\u76f4\u63a5\u4ece<code>product<\/code>\u8868\u83b7\u53d6\uff0c\u65e0\u9700 JOIN\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u9002\u7528\u573a\u666f<\/strong>\n<ol>\n<li><strong>\u9ad8\u9891\u67e5\u8be2\u3001\u4f4e\u9891\u66f4\u65b0<\/strong>\uff1a\u5982\u5546\u54c1\u8be6\u60c5\u9875\uff08\u67e5\u8be2\u9891\u7e41\uff0c\u5206\u7c7b\u540d\u79f0\u5f88\u5c11\u4fee\u6539\uff09\uff0c\u5197\u4f59\u540e\u67e5\u8be2\u6027\u80fd\u63d0\u5347 10 \u500d\u4ee5\u4e0a\uff1b<\/li>\n<li><strong>\u591a\u8868\u5173\u8054\u590d\u6742<\/strong>\uff1a\u5982\u8ba2\u5355\u5217\u8868\u9700\u5173\u8054\u7528\u6237\u8868\u3001\u5546\u54c1\u8868\u3001\u7269\u6d41\u8868\uff0c\u5197\u4f59 \u201c\u7528\u6237\u540d\u201d\u201c\u5546\u54c1\u540d\u201d \u540e\uff0c\u67e5\u8be2\u4ece\u591a\u8868 JOIN \u7b80\u5316\u4e3a\u5355\u8868\u67e5\u8be2\uff1b<\/li>\n<li><strong>\u7edf\u8ba1\u5206\u6790\u573a\u666f<\/strong>\uff1a\u62a5\u8868\u7cfb\u7edf\u9700\u805a\u5408\u591a\u7ef4\u5ea6\u6570\u636e\uff0c\u5197\u4f59\u5b58\u50a8\u805a\u5408\u7ed3\u679c\uff08\u5982 \u201c\u6bcf\u6708\u9500\u552e\u989d\u201d\uff09\uff0c\u907f\u514d\u5b9e\u65f6\u8ba1\u7b97\u3002<\/li>\n<\/ol>\n<\/li>\n<li><strong>\u6ce8\u610f\u4e8b\u9879<\/strong>\n<ul>\n<li>\u5197\u4f59\u5b57\u6bb5\u9700\u540c\u6b65\u66f4\u65b0\uff1a\u5982<code>category_name<\/code>\u4fee\u6539\u540e\uff0c\u9700\u540c\u6b65\u66f4\u65b0<code>product<\/code>\u8868\u4e2d\u7684\u5197\u4f59\u5b57\u6bb5\uff08\u53ef\u901a\u8fc7\u89e6\u53d1\u5668\u3001Java \u4ee3\u7801\u4e8b\u52a1\u4fdd\u8bc1\uff09\uff1b<\/li>\n<li>\u63a7\u5236\u5197\u4f59\u8303\u56f4\uff1a\u53ea\u5197\u4f59\u9ad8\u9891\u67e5\u8be2\u7684\u6838\u5fc3\u5b57\u6bb5\uff08\u5982\u540d\u79f0\u3001\u72b6\u6001\uff09\uff0c\u907f\u514d\u8868\u8fc7\u5927\uff08\u5982\u5197\u4f59\u5927\u6587\u672c\u5b57\u6bb5\u4f1a\u589e\u52a0\u5b58\u50a8\u548c IO \u6210\u672c\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>5. \u603b\u7ed3<\/h2>\n<ul>\n<li><strong>\u8303\u5f0f\uff1a<\/strong>\u9002\u5408\u5199\u591a\u8bfb\u5c11\u3001\u6570\u636e\u4e00\u81f4\u6027\u8981\u6c42\u9ad8\u7684\u573a\u666f\uff08\u5982\u8ba2\u5355\u7cfb\u7edf\u3001\u7528\u6237\u4e2d\u5fc3\uff09\uff0c\u901a\u8fc7\u51cf\u5c11\u5197\u4f59\u964d\u4f4e\u66f4\u65b0\u5f02\u5e38\u98ce\u9669\uff1b<\/li>\n<li><strong>\u53cd\u8303\u5f0f\uff1a<\/strong>\u9002\u5408\u8bfb\u591a\u5199\u5c11\u3001\u67e5\u8be2\u6027\u80fd\u654f\u611f\u7684\u573a\u666f\uff08\u5982\u7535\u5546\u5217\u8868\u3001\u62a5\u8868\uff09\uff0c\u901a\u8fc7\u53ef\u63a7\u5197\u4f59\u63d0\u5347\u67e5\u8be2\u6548\u7387\u3002<\/li>\n<li>\u5b9e\u9645\u5f00\u53d1\u4e2d\uff0c\u5f88\u5c11\u4e25\u683c\u9075\u5faa\u67d0\u4e00\u8303\u5f0f\uff0c\u800c\u662f<strong>\u6df7\u5408\u4f7f\u7528<\/strong>\uff08\u5982\u6838\u5fc3\u4ea4\u6613\u8868\u7528 3NF \u4fdd\u8bc1\u4e00\u81f4\u6027\uff0c\u67e5\u8be2\u8868\u7528\u53cd\u8303\u5f0f\u63d0\u5347\u6027\u80fd\uff09\u3002<\/li>\n<\/ul>\n<div style=\"height:1.5em\"><\/div>\n<h1>06. DDL\u3001DML\u3001DCL\u3001DQL<\/h1>\n<p>MySQL \u4e2d DDL\u3001DML\u3001DCL\u3001DQL \u662f\u6309\u64cd\u4f5c\u7c7b\u578b\u5212\u5206\u7684\u56db\u5927\u7c7b SQL \u8bed\u8a00\uff0c\u5206\u522b\u5bf9\u5e94\uff1a<\/p>\n<ul>\n<li>DDL\uff1a\u6570\u636e\u5e93\u7ed3\u6784\u5b9a\u4e49\uff1b<\/li>\n<li>DML\uff1a\u6570\u636e\u64cd\u7eb5\uff1b<\/li>\n<li>DCL\uff1a\u6743\u9650\u63a7\u5236\uff1b<\/li>\n<li>DQL\uff1a\u6570\u636e\u67e5\u8be2\u3002<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>1. DQL\uff1a\u6570\u636e\u67e5\u8be2\u8bed\u8a00<\/h2>\n<p>Data Query Language\u3002<\/p>\n<ul>\n<li><strong>\u5b9a\u4e49\uff1a<\/strong>\u7528\u4e8e\u4ece\u6570\u636e\u5e93\u4e2d\u67e5\u8be2\u6570\u636e\uff0c\u4e0d\u4fee\u6539\u6570\u636e\u6216\u7ed3\u6784\uff0c\u662f\u4e1a\u52a1\u7cfb\u7edf\u4e2d\u6700\u9891\u7e41\u7684\u64cd\u4f5c\u3002<\/li>\n<li><strong>\u6838\u5fc3\u547d\u4ee4\uff1a<\/strong><code>SELECT<\/code>\uff08\u542b<code>WHERE<\/code>\u3001<code>JOIN<\/code>\u3001<code>GROUP BY<\/code>\u3001<code>ORDER BY<\/code>\u3001<code>LIMIT<\/code>\u7b49\u5b50\u53e5\uff09\u3002<\/li>\n<li><strong>\u4f5c\u7528\uff1a<\/strong>\u4ece\u8868\u4e2d\u63d0\u53d6\u6240\u9700\u6570\u636e\uff0c\u652f\u6491\u4e1a\u52a1\u5c55\u793a\uff08\u5982\u5217\u8868\u9875\u3001\u8be6\u60c5\u9875\uff09\u3001\u7edf\u8ba1\u5206\u6790\uff08\u5982\u62a5\u8868\uff09\u7b49\u573a\u666f\u3002<\/li>\n<li><strong>\u5b9e\u8df5\u8981\u70b9\uff1a<\/strong>\n<ul>\n<li>\u662f Java \u5f00\u53d1\u4e2d\u6700\u5e38\u7528\u7684 SQL\uff08\u5982\u67e5\u8be2\u7528\u6237\u4fe1\u606f\u3001\u8ba2\u5355\u5217\u8868\uff09\uff0c\u9700\u7ed3\u5408\u7d22\u5f15\u4f18\u5316\uff08\u5982<code>WHERE<\/code>\u6761\u4ef6\u52a0\u7d22\u5f15\u3001\u907f\u514d<code>SELECT *<\/code>\uff09\uff1b<\/li>\n<li>\u590d\u6742\u67e5\u8be2\uff08\u591a\u8868\u5173\u8054\u3001\u805a\u5408\uff09\u9700\u7528<code>EXPLAIN<\/code>\u5206\u6790\u6267\u884c\u8ba1\u5212\uff0c\u907f\u514d\u5168\u8868\u626b\u63cf\u6216\u6587\u4ef6\u6392\u5e8f\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>2. DML\uff1a\u6570\u636e\u64cd\u7eb5\u8bed\u8a00<\/h2>\n<p>Data Manipulation Language\u3002<\/p>\n<ul>\n<li><strong>\u5b9a\u4e49\uff1a<\/strong>\u7528\u4e8e\u4fee\u6539\u8868\u4e2d\u7684\u6570\u636e\uff08\u589e\u3001\u5220\u3001\u6539\uff09\uff0c\u4f1a\u6539\u53d8\u6570\u636e\u5185\u5bb9\uff0c\u4f46\u4e0d\u6539\u53d8\u8868\u7ed3\u6784\u3002<\/li>\n<li><strong>\u6838\u5fc3\u547d\u4ee4\uff1a<\/strong>\n<ul>\n<li><code>INSERT<\/code>\uff08\u65b0\u589e\uff09\uff1b<\/li>\n<li><code>UPDATE<\/code>\uff08\u4fee\u6539\uff09\uff1b<\/li>\n<li><code>DELETE<\/code>\uff08\u5220\u9664\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u4f5c\u7528\uff1a<\/strong>\u5904\u7406\u4e1a\u52a1\u6570\u636e\u7684\u751f\u547d\u5468\u671f\uff08\u5982\u521b\u5efa\u8ba2\u5355\u3001\u66f4\u65b0\u72b6\u6001\u3001\u5220\u9664\u65e0\u6548\u8bb0\u5f55\uff09\u3002<\/li>\n<li><strong>\u5b9e\u8df5\u8981\u70b9\uff1a<\/strong>\n<ul>\n<li>\u64cd\u4f5c\u4f1a\u89e6\u53d1\u4e8b\u52a1\uff08\u9ed8\u8ba4\u81ea\u52a8\u63d0\u4ea4\uff0c\u53ef\u901a\u8fc7<code>BEGIN<\/code>\u624b\u52a8\u63a7\u5236\uff09\uff0c\u9700\u4fdd\u8bc1\u539f\u5b50\u6027\uff08\u5982\u8ba2\u5355\u521b\u5efa\u65f6\u540c\u65f6\u6263\u51cf\u5e93\u5b58\uff0c\u5931\u8d25\u5219\u56de\u6eda\uff09\uff1b<\/li>\n<li>\u6279\u91cf\u64cd\u4f5c\u4f18\u5316\uff1a<code>INSERT<\/code>\u7528<code>VALUES (),(),()<\/code>\u6279\u91cf\u63d2\u5165\uff08\u6bd4\u5355\u6761\u5faa\u73af\u9ad8\u6548\uff09\uff0c<code>DELETE<\/code>\/<code>UPDATE<\/code>\u907f\u514d\u5168\u8868\u64cd\u4f5c\uff08\u52a0<code>WHERE<\/code>\u6761\u4ef6\uff0c\u5982<code>DELETE FROM log WHERE create_time &lt; &#039;2024-01-01&#039;<\/code>\uff09\uff1b<\/li>\n<li>\u9ad8\u9891\u5199\u5165\u573a\u666f\uff08\u5982\u65e5\u5fd7\uff09\u9700\u63a7\u5236\u9891\u7387\uff0c\u907f\u514d\u9501\u8868\u5f71\u54cd\u67e5\u8be2\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>3. DDL\uff1a\u6570\u636e\u5b9a\u4e49\u8bed\u8a00<\/h2>\n<p>Data Definition Language\u3002<\/p>\n<ul>\n<li><strong>\u5b9a\u4e49\uff1a<\/strong>\u7528\u4e8e\u5b9a\u4e49\u6216\u4fee\u6539\u6570\u636e\u5e93\u3001\u8868\u3001\u7d22\u5f15\u7b49\u7ed3\u6784\uff0c\u4f1a\u6539\u53d8\u6570\u636e\u5e93\u7684\u5143\u6570\u636e\uff08\u7ed3\u6784\u4fe1\u606f\uff09\u3002<\/li>\n<li><strong>\u6838\u5fc3\u547d\u4ee4\uff1a<\/strong>\n<ul>\n<li><code>CREATE<\/code>\uff08\u521b\u5efa\uff0c\u5982<code>CREATE TABLE<\/code>\u3001<code>CREATE INDEX<\/code>\uff09\uff1b<\/li>\n<li><code>ALTER<\/code>\uff08\u4fee\u6539\uff0c\u5982<code>ALTER TABLE ADD COLUMN<\/code>\uff09\uff1b<\/li>\n<li><code>DROP<\/code>\uff08\u5220\u9664\uff0c\u5982<code>DROP TABLE<\/code>\uff09\uff1b<\/li>\n<li><code>TRUNCATE<\/code>\uff08\u6e05\u7a7a\u8868\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u4f5c\u7528\uff1a<\/strong>\u521d\u59cb\u5316\u6570\u636e\u5e93\u7ed3\u6784\uff08\u5982\u5efa\u8868\u3001\u52a0\u5b57\u6bb5\uff09\u3001\u8c03\u6574\u8868\u7ed3\u6784\uff08\u5982\u65b0\u589e\u7d22\u5f15\u3001\u6269\u5c55\u5b57\u6bb5\uff09\u3002<\/li>\n<li><strong>\u5b9e\u8df5\u8981\u70b9\uff1a<\/strong>\n<ul>\n<li>\u6267\u884c\u65f6\u53ef\u80fd\u9501\u8868\uff08\u5c24\u5176<code>ALTER TABLE<\/code>\u5728 InnoDB \u4e2d\uff0c\u5927\u8868\u4fee\u6539\u4f1a\u963b\u585e\u8bfb\u5199\uff09\uff0c\u751f\u4ea7\u73af\u5883\u9700\u5728\u4f4e\u5cf0\u671f\u6267\u884c\uff0c\u5927\u8868\u5efa\u8bae\u7528\u5728\u7ebf DDL \u5de5\u5177\uff08\u5982 pt-online-schema-change\uff09\uff1b<\/li>\n<li>\u8c28\u614e\u4f7f\u7528<code>DROP<\/code>\u548c<code>TRUNCATE<\/code>\uff08\u4e0d\u53ef\u9006\uff0cTRUNCATE\u4f1a\u6e05\u7a7a\u6570\u636e\u4e14\u4e0d\u89e6\u53d1\u4e8b\u52a1\u56de\u6eda\uff09\uff1b<\/li>\n<li>\u7d22\u5f15\u76f8\u5173 DDL\uff08<code>CREATE INDEX<\/code>\uff09\u9700\u8bc4\u4f30\u5fc5\u8981\u6027\uff08\u7d22\u5f15\u63d0\u5347\u67e5\u8be2\u4f46\u964d\u4f4e\u5199\u5165\u6027\u80fd\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>4. DCL\uff1a\u6570\u636e\u63a7\u5236\u8bed\u8a00<\/h2>\n<p>Data Control Language\u3002<\/p>\n<ul>\n<li><strong>\u5b9a\u4e49\uff1a<\/strong>\u7528\u4e8e\u7ba1\u7406\u6570\u636e\u5e93\u7528\u6237\u6743\u9650\u548c\u4e8b\u52a1\u63a7\u5236\uff0c\u63a7\u5236\u8c01\u80fd\u64cd\u4f5c\u6570\u636e\u3001\u64cd\u4f5c\u8303\u56f4\u3002<\/li>\n<li><strong>\u6838\u5fc3\u547d\u4ee4\uff1a<\/strong>`\n<ul>\n<li>GRANT`\uff08\u6388\u4e88\u6743\u9650\uff09\uff1b<\/li>\n<li><code>REVOKE<\/code>\uff08\u64a4\u9500\u6743\u9650\uff09\uff1b<\/li>\n<li><code>COMMIT<\/code>\uff08\u63d0\u4ea4\u4e8b\u52a1\uff09\uff1b<\/li>\n<li><code>ROLLBACK<\/code>\uff08\u56de\u6eda\u4e8b\u52a1\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<li><strong>\u4f5c\u7528\uff1a<\/strong>\u4fdd\u969c\u6570\u636e\u5b89\u5168\uff08\u5982\u9650\u5236\u5e94\u7528\u8d26\u53f7\u53ea\u80fd\u64cd\u4f5c\u6307\u5b9a\u8868\uff09\u3001\u63a7\u5236\u4e8b\u52a1\u4e00\u81f4\u6027\u3002<\/li>\n<li><strong>\u5b9e\u8df5\u8981\u70b9\uff1a<\/strong>\n<ul>\n<li>\u6743\u9650\u9075\u5faa \u201c\u6700\u5c0f\u539f\u5219\u201d\uff1a\u5e94\u7528\u7a0b\u5e8f\u8d26\u53f7\u53ea\u6388\u4e88<code>SELECT<\/code>\/<code>INSERT<\/code>\/<code>UPDATE<\/code>\u7b49\u5fc5\u8981\u6743\u9650\uff0c\u7981\u6b62<code>DROP<\/code>\/<code>GRANT<\/code>\u7b49\u9ad8\u98ce\u9669\u6743\u9650\uff0c\u907f\u514d\u7528 root \u8d26\u53f7\u76f4\u63a5\u8fde\u63a5\u4e1a\u52a1\u7cfb\u7edf\uff1b<\/li>\n<li>\u4e8b\u52a1\u63a7\u5236\uff08<code>COMMIT<\/code>\/<code>ROLLBACK<\/code>\uff09\u9700\u5728 Java \u4ee3\u7801\u4e2d\u914d\u5408\u4e1a\u52a1\u903b\u8f91\uff08\u5982\u5206\u5e03\u5f0f\u4e8b\u52a1\u573a\u666f\uff0c\u786e\u4fdd\u591a\u5e93\u64cd\u4f5c\u4e00\u81f4\u6027\uff09\u3002<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<div style=\"height:1em\"><\/div>\n<h2>5. \u603b\u7ed3<\/h2>\n<p>\u56db\u7c7b\u8bed\u8a00\u5206\u5de5\u660e\u786e\uff1a<\/p>\n<ul>\n<li>DQL\uff1a\u67e5\u6570\u636e\uff08\u4e1a\u52a1\u5c55\u793a\u6838\u5fc3\uff09\uff1b<\/li>\n<li>DML\uff1a\u6539\u6570\u636e\uff08\u4e1a\u52a1\u64cd\u4f5c\u6838\u5fc3\uff09\uff1b<\/li>\n<li>DDL\uff1a\u6539\u7ed3\u6784\uff08\u67b6\u6784\u7ef4\u62a4\u6838\u5fc3\uff09\uff1b<\/li>\n<li>DCL\uff1a\u63a7\u6743\u9650\uff08\u5b89\u5168\u4fdd\u969c\u6838\u5fc3\uff09\u3002<\/li>\n<\/ul>\n<div style=\"height:1.5em\"><\/div>\n<h1>07. \u6570\u636e\u5e93\u8868\u5b57\u6bb5\u7c7b\u578b<\/h1>\n<h2>1. \u6838\u5fc3\u5b57\u6bb5\u7c7b\u578b\u53ca\u9002\u7528\u573a\u666f<\/h2>\n<h3>1. \u6570\u503c\u578b\uff1a\u9002\u5408\u5b58\u50a8\u6570\u5b57\uff08\u6574\u6570\u3001\u5c0f\u6570\uff09<\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u7279\u70b9\uff08\u957f\u5ea6 \/ \u8303\u56f4\uff09<\/th>\n<th style=\"text-align: center;\">JDK8\u5bf9\u5e94\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u9002\u7528\u573a\u666f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><code>TINYINT<\/code><\/td>\n<td style=\"text-align: left;\">1 \u5b57\u8282\uff0c\u8303\u56f4 &#8211; 128 ~ 127<br \/>\uff08\u65e0\u7b26\u53f7 0 ~ 255\uff09<\/td>\n<td style=\"text-align: center;\"><code>Byte<\/code><\/td>\n<td style=\"text-align: left;\">\u72b6\u6001\u6807\u8bc6\uff08\u5982<code>status<\/code>\uff1a0 &#8211; \u7981\u7528\u30011 &#8211; \u6b63\u5e38\uff09\u3001<br \/>\u6027\u522b\uff080 &#8211; \u5973\u30011 &#8211; \u7537\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>INT<\/code><\/td>\n<td style=\"text-align: left;\">4 \u5b57\u8282\uff0c\u8303\u56f4 &#8211; 21 \u4ebf \uff5e 21 \u4ebf<\/td>\n<td style=\"text-align: center;\"><code>Integer<\/code><\/td>\n<td style=\"text-align: left;\">\u666e\u901a ID\uff08\u5982<code>user_id<\/code>\u3001<code>order_id<\/code>\uff0c\u4e2d\u5c0f\u89c4\u6a21\u4e1a\u52a1\u8db3\u591f\uff09\u3001\u6570\u91cf\uff08\u5982<code>count<\/code>\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>BIGINT<\/code><\/td>\n<td style=\"text-align: left;\">8 \u5b57\u8282\uff0c\u8303\u56f4 \u00b19e18\uff0c<br \/>\u5927\u7ea6\u00b190\u4ebf\u4ebf<\/td>\n<td style=\"text-align: center;\"><code>Long<\/code><\/td>\n<td style=\"text-align: left;\">\u5927\u6574\u6570 ID\uff08\u5982\u5206\u5e03\u5f0f ID\u3001\u96ea\u82b1 ID\uff09\u3001<br \/>\u9ad8\u9891\u589e\u957f\u6570\u636e\uff08\u5982\u4e07\u4ebf\u7ea7\u8ba2\u5355\u91cf\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>DECIMAL(M,D)<\/code><\/td>\n<td style=\"text-align: left;\">\u9ad8\u7cbe\u5ea6\u5c0f\u6570<br \/>\uff08M \u603b\u957f\u5ea6\uff0cD \u5c0f\u6570\u4f4d\uff09<\/td>\n<td style=\"text-align: center;\"><code>java.math.BigDecimal<\/code><\/td>\n<td style=\"text-align: left;\">\u91d1\u989d\uff08\u5982<code>amount<\/code>\uff1a<code>DECIMAL(10,2)<\/code>\u8868\u793a<br \/>\u6700\u591a 10 \u4f4d\uff0c2 \u4f4d\u5c0f\u6570\uff09\u3001\u5229\u7387<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>FLOAT\/DOUBLE<\/code><\/td>\n<td style=\"text-align: left;\">\u5355 \/ \u53cc\u7cbe\u5ea6\u6d6e\u70b9<br \/>\uff08\u6709\u7cbe\u5ea6\u635f\u5931\uff09<\/td>\n<td style=\"text-align: center;\"><code>Float<\/code>\/<code>Double<\/code><\/td>\n<td style=\"text-align: left;\">\u975e\u7cbe\u786e\u8ba1\u7b97\uff08\u5982\u6e29\u5ea6\u3001\u91cd\u91cf\uff0c\u5141\u8bb8\u5fae\u5c0f\u8bef\u5dee\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div style=\"height:1em\"><\/div>\n<h3>2. \u5b57\u7b26\u4e32\u578b\uff1a\u9002\u5408\u5b58\u50a8\u6587\u672c<\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u7279\u70b9\uff08\u957f\u5ea6 \/ \u8303\u56f4\uff09<\/th>\n<th style=\"text-align: center;\">JDK8\u5bf9\u5e94\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u9002\u7528\u573a\u666f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><code>CHAR(N)<\/code><\/td>\n<td style=\"text-align: left;\">\u56fa\u5b9a\u957f\u5ea6\uff08N \u5b57\u8282\uff0c0 ~ 255\uff09\uff0c<br \/>\u7a7a\u683c\u586b\u5145<\/td>\n<td style=\"text-align: center;\"><code>String<\/code><\/td>\n<td style=\"text-align: left;\">\u957f\u5ea6\u56fa\u5b9a\u7684\u5b57\u7b26\u4e32\uff08\u5982\u624b\u673a\u53f7<code>CHAR(11)<\/code>\u3001\u8eab\u4efd\u8bc1\u53f7<code>CHAR(18)<\/code>\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>VARCHAR(N)<\/code><\/td>\n<td style=\"text-align: left;\">\u53ef\u53d8\u957f\u5ea6\uff080 ~ 65535\uff09\uff0c<br \/>\u5b58\u50a8\u5b9e\u9645\u957f\u5ea6<\/td>\n<td style=\"text-align: center;\"><code>String<\/code><\/td>\n<td style=\"text-align: left;\">\u957f\u5ea6\u4e0d\u56fa\u5b9a\u7684\u6587\u672c\uff08\u5982\u7528\u6237\u540d<code>VARCHAR(50)<\/code>\u3001\u5730\u5740<code>VARCHAR(200)<\/code>\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>TEXT<\/code><\/td>\n<td style=\"text-align: left;\">\u5927\u6587\u672c\uff08\u6700\u5927 64KB\uff09<\/td>\n<td style=\"text-align: center;\"><code>String<\/code><\/td>\n<td style=\"text-align: left;\">\u8f83\u957f\u6587\u672c\uff08\u5982\u5546\u54c1\u63cf\u8ff0\u3001\u7528\u6237\u5907\u6ce8\uff0c\u4e0d\u9002\u5408\u5efa\u7d22\u5f15\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>MEDIUMTEXT\/LONGTEXT<\/code><\/td>\n<td style=\"text-align: left;\">\u66f4\u5927\u6587\u672c\uff0816MB\/4GB\uff09<\/td>\n<td style=\"text-align: center;\"><code>String<\/code><\/td>\n<td style=\"text-align: left;\">\u8d85\u5927\u6587\u672c\uff08\u5982\u6587\u7ae0\u5185\u5bb9\u3001\u65e5\u5fd7\u8be6\u60c5\uff0c\u614e\u7528\uff0c\u4f1a\u62d6\u6162\u67e5\u8be2\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div style=\"height:1em\"><\/div>\n<h3>3. \u65e5\u671f\u65f6\u95f4\u578b\uff1a\u9002\u5408\u5b58\u50a8\u65f6\u95f4<\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u7279\u70b9\uff08\u957f\u5ea6 \/ \u8303\u56f4\uff09<\/th>\n<th style=\"text-align: center;\">JDK8\u5bf9\u5e94\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u9002\u7528\u573a\u666f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><code>DATETIME<\/code><\/td>\n<td style=\"text-align: left;\">8 \u5b57\u8282\uff0c\u8303\u56f4 1000 ~ 9999 \u5e74\uff0c<br \/>\u65e0\u65f6\u533a<\/td>\n<td style=\"text-align: center;\"><code>java.time.LocalDateTime<\/code><br \/>\uff08\u4e0d\u63a8\u8350<code>Date<\/code>\uff09<\/td>\n<td style=\"text-align: left;\">\u4e1a\u52a1\u65f6\u95f4\uff08\u5982\u8ba2\u5355\u521b\u5efa\u65f6\u95f4<code>create_time<\/code>\uff0c\u4e0d\u53d7\u670d\u52a1\u5668\u65f6\u533a\u5f71\u54cd\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>TIMESTAMP<\/code><\/td>\n<td style=\"text-align: left;\">4 \u5b57\u8282\uff0c\u8303\u56f4 1970 ~ 2038 \u5e74\uff0c<br \/>\u53d7\u65f6\u533a\u5f71\u54cd<\/td>\n<td style=\"text-align: center;\"><code>java.time.LocalDateTime<\/code><br \/>\uff08\u4e0d\u63a8\u8350<code>Date<\/code>\uff09<\/td>\n<td style=\"text-align: left;\">\u8bb0\u5f55\u7cfb\u7edf\u65f6\u95f4\uff08\u5982\u6700\u540e\u66f4\u65b0\u65f6\u95f4<code>update_time<\/code>\uff0c\u81ea\u52a8\u968f\u65f6\u533a\u8f6c\u6362\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>DATE<\/code><\/td>\n<td style=\"text-align: left;\">3 \u5b57\u8282\uff0c\u4ec5\u65e5\u671f\uff08\u5e74\u6708\u65e5\uff09<\/td>\n<td style=\"text-align: center;\"><code>java.time.LocalDate<\/code><br \/>\uff08\u4e0d\u63a8\u8350<code>Timestamp<\/code>\uff09<\/td>\n<td style=\"text-align: left;\">\u751f\u65e5\u3001\u5230\u671f\u65e5\uff08\u5982<code>birthday<\/code>\u3001<code>expire_date<\/code>\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>TIME<\/code><\/td>\n<td style=\"text-align: left;\">3 \u5b57\u8282\uff0c\u4ec5\u65f6\u95f4\uff08\u65f6\u5206\u79d2\uff09<\/td>\n<td style=\"text-align: center;\"><code>java.time.LocalTime<\/code><\/td>\n<td style=\"text-align: left;\">\u65f6\u6bb5\u8bb0\u5f55\uff08\u5982\u4f1a\u8bae\u65f6\u957f\u3001\u6253\u5361\u65f6\u95f4\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div style=\"height:1em\"><\/div>\n<h3>4. \u7279\u6b8a\u7c7b\u578b\uff1a\u9488\u5bf9\u6027\u573a\u666f<\/h3>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left;\">\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u7279\u70b9\uff08\u957f\u5ea6 \/ \u8303\u56f4\uff09<\/th>\n<th style=\"text-align: center;\">JDK8\u5bf9\u5e94\u7c7b\u578b<\/th>\n<th style=\"text-align: left;\">\u9002\u7528\u573a\u666f<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left;\"><code>ENUM<\/code><\/td>\n<td style=\"text-align: left;\">\u679a\u4e3e\uff08\u5b58\u50a8\u6574\u6570\uff0c\u663e\u793a\u5b57\u7b26\u4e32\uff09<\/td>\n<td style=\"text-align: center;\"><code>String<\/code><\/td>\n<td style=\"text-align: left;\">\u56fa\u5b9a\u53ef\u9009\u503c\uff08\u5982<code>pay_type<\/code>\uff1a<code>ENUM(&#039;WECHAT&#039;,&#039;ALIPAY&#039;,&#039;CARD&#039;)<\/code>\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>SET<\/code><\/td>\n<td style=\"text-align: left;\">\u96c6\u5408\uff08\u591a\u9009\uff0c\u6700\u591a 64 \u4e2a\u503c\uff09<\/td>\n<td style=\"text-align: center;\"><code>String<\/code><\/td>\n<td style=\"text-align: left;\">\u591a\u9009\u9879\uff08\u5982<code>tags<\/code>\uff1a<code>SET(&#039;hot&#039;,&#039;new&#039;,&#039;discount&#039;)<\/code>\uff09<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left;\"><code>BLOB<\/code><\/td>\n<td style=\"text-align: left;\">\u4e8c\u8fdb\u5236\u6570\u636e\uff08\u5982\u56fe\u7247\u3001\u6587\u4ef6\uff09<\/td>\n<td style=\"text-align: center;\"><code>byte[]<\/code>\uff08\u5b57\u8282\u6570\u7ec4\uff09<\/td>\n<td style=\"text-align: left;\">\u5c0f\u578b\u4e8c\u8fdb\u5236\uff08\u5982\u5934\u50cf\u7f29\u7565\u56fe\uff0c\u5927\u578b\u6587\u4ef6\u5efa\u8bae\u5b58 OSS\uff0c\u5e93\u4e2d\u53ea\u5b58 URL\uff09<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<div style=\"height:1.5em\"><\/div>\n<h2>2. \u7ecf\u5178\u9762\u8bd5\u70b9<\/h2>\n<h3>1. \u6570\u503c\u578b\uff1a\u7cbe\u5ea6\u4e0e\u8303\u56f4\u9677\u9631<\/h3>\n<ul>\n<li>\n<p><strong>\u91d1\u989d\u4e3a\u4ec0\u4e48\u7528<code>DECIMAL<\/code>\u800c\u975e<code>FLOAT<\/code>\uff1f<\/strong><br \/>\n<code>FLOAT<\/code>\u662f\u6d6e\u70b9\u578b\uff0c\u5b58\u5728\u7cbe\u5ea6\u635f\u5931\uff08\u5982<code>0.1 + 0.2 = 0.300000004<\/code>\uff09\uff0c\u800c<code>DECIMAL<\/code>\u662f\u7cbe\u786e\u5c0f\u6570\uff0c\u9002\u5408\u91d1\u989d\u7b49\u5f3a\u7cbe\u5ea6\u573a\u666f\u3002<\/p>\n<\/li>\n<li>\n<p><strong><code>INT<\/code>\u548c<code>BIGINT<\/code>\u600e\u4e48\u9009\uff1f<\/strong><br \/>\n\u4e2d\u5c0f\u4e1a\u52a1\uff08\u5343\u4e07\u7ea7\u6570\u636e\uff09\u7528<code>INT<\/code>\u8db3\u591f\uff1b\u5206\u5e03\u5f0f\u7cfb\u7edf\uff08\u5982\u8ba2\u5355 ID \u7528\u96ea\u82b1 ID\uff0c\u957f\u5ea6 18 \u4f4d\uff09\u5fc5\u987b\u7528<code>BIGINT<\/code>\uff0c\u907f\u514d\u6ea2\u51fa\u3002<\/p>\n<\/li>\n<\/ul>\n<div style=\"height:0.7em\"><\/div>\n<h3>2. \u5b57\u7b26\u4e32\u578b\uff1a\u957f\u5ea6\u4e0e\u6027\u80fd<\/h3>\n<ul>\n<li>\n<p><strong><code>CHAR<\/code>\u548c<code>VARCHAR<\/code>\u7684\u6838\u5fc3\u533a\u522b\uff1f<\/strong><br \/>\n<code>CHAR<\/code>\u56fa\u5b9a\u957f\u5ea6\uff0c\u67e5\u8be2\u5feb\u4f46\u6d6a\u8d39\u7a7a\u95f4\uff08\u5982\u624b\u673a\u53f7\u7528<code>CHAR(11)<\/code>\u6bd4<code>VARCHAR(11)<\/code>\u9ad8\u6548\uff0c\u65e0\u9700\u8ba1\u7b97\u957f\u5ea6\uff09\uff1b<br \/>\n<code>VARCHAR<\/code>\u8282\u7701\u7a7a\u95f4\uff0c\u4f46\u67e5\u8be2\u9700\u989d\u5916\u89e3\u6790\u957f\u5ea6\uff0c\u9002\u5408\u957f\u5ea6\u6ce2\u52a8\u5927\u7684\u573a\u666f\uff08\u5982\u5730\u5740\uff09\u3002<\/p>\n<\/li>\n<li>\n<p><strong>\u4e3a\u4ec0\u4e48\u4e0d\u5efa\u8bae<code>VARCHAR(255)<\/code>\u6ee5\u7528\uff1f<\/strong><br \/>\nMySQL \u4e2d<code>VARCHAR(255)<\/code>\u5728\u67d0\u4e9b\u5f15\u64ce\uff08\u5982 <code>InnoDB<\/code>\uff09\u4e2d\u4f1a\u6309 255 \u5b57\u8282\u5206\u914d\u4e34\u65f6\u5185\u5b58\uff0c\u5373\u4f7f\u5b9e\u9645\u6570\u636e\u5f88\u77ed\uff0c\u4e5f\u4f1a\u6d6a\u8d39\u5185\u5b58\uff08\u5c24\u5176\u6392\u5e8f\u3001<code>JOIN<\/code> \u65f6\uff09\uff0c\u5efa\u8bae\u6309\u5b9e\u9645\u9700\u6c42\u8bbe\u957f\u5ea6\uff08\u5982\u7528\u6237\u540d<code>VARCHAR(50)<\/code>\uff09\u3002<\/p>\n<\/li>\n<li>\n<p><strong><code>TEXT<\/code>\u7c7b\u578b\u7684\u5751\uff1f<\/strong><br \/>\n<code>TEXT<\/code>\u5b57\u6bb5\u4e0d\u9002\u5408\u5efa\u7d22\u5f15\uff08\u5373\u4f7f\u5efa\u7d22\u5f15\u4e5f\u53ea\u80fd\u53d6\u524d N \u4e2a\u5b57\u7b26\uff09\uff0c\u4e14\u67e5\u8be2\u65f6\u4f1a\u989d\u5916 IO\uff0c\u5927\u6587\u672c\u5efa\u8bae\u62c6\u5206\u8868\uff08\u5982\u5546\u54c1\u8868\u5b58<code>desc_id<\/code>\uff0c\u5173\u8054\u5355\u72ec\u7684<code>product_desc<\/code>\u8868\u5b58<code>TEXT<\/code>\u5185\u5bb9\uff09\u3002<\/p>\n<\/li>\n<\/ul>\n<div style=\"height:0.7em\"><\/div>\n<h3>3. \u65e5\u671f\u65f6\u95f4\u578b\uff1a\u65f6\u533a\u4e0e\u8303\u56f4<\/h3>\n<ul>\n<li>\n<p><strong><code>DATETIME<\/code>\u548c<code>TIMESTAMP<\/code>\u600e\u4e48\u9009\uff1f<\/strong><br \/>\n\u4e1a\u52a1\u65f6\u95f4\uff08\u5982\u8ba2\u5355\u521b\u5efa\u65f6\u95f4\uff09\u7528<code>DATETIME<\/code>\uff08\u56fa\u5b9a\u503c\uff0c\u4e0d\u53d7\u670d\u52a1\u5668\u65f6\u533a\u5f71\u54cd\uff09\uff1b\u7cfb\u7edf\u65f6\u95f4\uff08\u5982\u6700\u540e\u4fee\u6539\u65f6\u95f4\uff09\u7528<code>TIMESTAMP<\/code>\uff08\u81ea\u52a8\u66f4\u65b0\uff0c\u9002\u914d\u591a\u65f6\u533a\u90e8\u7f72\uff09\u3002<\/p>\n<\/li>\n<li>\n<p><strong><code>TIMESTAMP<\/code>\u7684 2038 \u5e74\u95ee\u9898\uff1f<\/strong><br \/>\n\u56e0\u8303\u56f4\u662f 1970 ~ 2038 \u5e74\uff0c\u957f\u671f\u7cfb\u7edf\u9700\u6ce8\u610f\uff08\u53ef\u6539\u7528<code>DATETIME<\/code>\u89c4\u907f\uff09\u3002<\/p>\n<\/li>\n<\/ul>\n<h3>4. \u679a\u4e3e\u7c7b\u578b<code>ENUM<\/code>\u7684\u5229\u5f0a<\/h3>\n<ul>\n<li>\u4f18\u70b9\uff1a\u5b58\u50a8\u9ad8\u6548\uff08\u7528\u6574\u6570\u5b58\u5b57\u7b26\u4e32\uff09\uff0c\u7ea6\u675f\u6570\u636e\u5408\u6cd5\u6027\uff08\u53ea\u80fd\u9009\u5b9a\u4e49\u7684\u503c\uff09\uff1b<\/li>\n<li>\u7f3a\u70b9\uff1a\u4fee\u6539\u679a\u4e3e\u503c\u9700<code>ALTER TABLE<\/code>\uff08DDL \u64cd\u4f5c\uff0c\u5927\u8868\u963b\u585e\uff09\uff0c\u4e0d\u9002\u5408\u503c\u9891\u7e41\u53d8\u5316\u7684\u573a\u666f\uff08\u5982\u6d3b\u52a8\u72b6\u6001\uff0c\u5efa\u8bae\u7528<code>TINYINT<\/code>+ \u5b57\u5178\u8868\u66ff\u4ee3\uff09\u3002<\/li>\n<\/ul>\n<div style=\"height:1.5em\"><\/div>\n<h2>3. \u603b\u7ed3<\/h2>\n<p>\u5b57\u6bb5\u7c7b\u578b\u9009\u62e9\u7684\u6838\u5fc3\u539f\u5219\uff1a\u201c<strong>\u591f\u7528\u5373\u53ef\uff0c\u907f\u514d\u5197\u4f59<\/strong>\u201d<\/p>\n<ul>\n<li>\u6570\u5b57\u4f18\u5148\u9009\u5c0f\u7c7b\u578b\uff08\u5982\u72b6\u6001\u7528<code>TINYINT<\/code>\u800c\u975e<code>INT<\/code>\uff09\uff1b<\/li>\n<li>\u5b57\u7b26\u4e32\u6309\u957f\u5ea6\u56fa\u5b9a\u4e0e\u5426\u9009<code>CHAR<\/code>\/<code>VARCHAR<\/code>\uff0c\u907f\u514d\u5927\u6587\u672c\u5b57\u6bb5\u62d6\u7d2f\u4e3b\u8868\uff1b<\/li>\n<li>\u65e5\u671f\u6839\u636e\u65f6\u533a\u9700\u6c42\u9009<code>DATETIME<\/code>\/<code>TIMESTAMP<\/code>\uff1b<\/li>\n<li>\u91d1\u989d\u3001ID \u7b49\u5173\u952e\u5b57\u6bb5\u5fc5\u987b\u4fdd\u8bc1\u7cbe\u5ea6\u548c\u8303\u56f4\uff0c\u907f\u514d\u6ea2\u51fa\u6216\u7cbe\u5ea6\u4e22\u5931\u3002<\/li>\n<\/ul>\n<div style=\"height:1.5em\"><\/div>\n<blockquote>\n<p>\u56de\u76ee\u5f55\uff1a <a href=\"https:\/\/www.tqazy.com\/?p=1972\" target=\"_blank\">\u300a\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u5173\u76ee\u5f55\u300b<\/a><br \/>\n\u4e0b\u4e00\u7bc7\uff1a <a href=\"https:\/\/www.tqazy.com\/?p=2082\" target=\"_blank\">\u300a\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517302 \u2013 \u7d22\u5f15\u300b<\/a><\/p>\n<\/blockquote>\n","protected":false},"excerpt":{"rendered":"<p>\u6574\u4f53\u67b6\u6784\u3001\u6838\u5fc3\u7ec4\u4ef6\u3001\u5b58\u50a8\u5f15\u64ce\u3001InnoDB\u5b58\u50a8\u5f15\u64ce\u3001\u4e09\u5927\u8303\u5f0f\u548c\u53cd\u8303\u5f0f\u3001DDL\/DML\/DCL\/DQL\u3001\u6570\u636e\u5e93\u8868\u5b57\u6bb5\u7c7b\u578b\u3002\u672c\u6587\u4f1a\u6301\u7eed\u66f4\u65b0&#8230;<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[84],"tags":[109,85],"class_list":["post-2077","post","type-post","status-publish","format-standard","hentry","category-interview","tag-mysql","tag-85"],"yoast_head":"<!-- This site is optimized with the Yoast SEO plugin v24.5 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517301 - \u57fa\u7840\u6838\u5fc3 | \u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2<\/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.tqazy.com\/?p=2077\" \/>\n<meta property=\"og:locale\" content=\"zh_CN\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517301 - \u57fa\u7840\u6838\u5fc3 | \u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2\" \/>\n<meta property=\"og:description\" content=\"\u6574\u4f53\u67b6\u6784\u3001\u6838\u5fc3\u7ec4\u4ef6\u3001\u5b58\u50a8\u5f15\u64ce\u3001InnoDB\u5b58\u50a8\u5f15\u64ce\u3001\u4e09\u5927\u8303\u5f0f\u548c\u53cd\u8303\u5f0f\u3001DDL\/DML\/DCL\/DQL\u3001\u6570\u636e\u5e93\u8868\u5b57\u6bb5\u7c7b\u578b\u3002\u672c\u6587\u4f1a\u6301\u7eed\u66f4\u65b0...\" \/>\n<meta property=\"og:url\" content=\"https:\/\/www.tqazy.com\/?p=2077\" \/>\n<meta property=\"og:site_name\" content=\"\u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2\" \/>\n<meta property=\"article:published_time\" content=\"2025-11-20T04:37:13+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2025-11-20T07:07:41+00:00\" \/>\n<meta property=\"og:image\" content=\"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png\" \/>\n<meta name=\"author\" content=\"\u9676\u5176\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<meta name=\"twitter:label1\" content=\"\u4f5c\u8005\" \/>\n\t<meta name=\"twitter:data1\" content=\"\u9676\u5176\" \/>\n\t<meta name=\"twitter:label2\" content=\"\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4\" \/>\n\t<meta name=\"twitter:data2\" content=\"5 \u5206\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"Article\",\"@id\":\"https:\/\/www.tqazy.com\/?p=2077#article\",\"isPartOf\":{\"@id\":\"https:\/\/www.tqazy.com\/?p=2077\"},\"author\":{\"name\":\"\u9676\u5176\",\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e\"},\"headline\":\"\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517301 &#8211; \u57fa\u7840\u6838\u5fc3\",\"datePublished\":\"2025-11-20T04:37:13+00:00\",\"dateModified\":\"2025-11-20T07:07:41+00:00\",\"mainEntityOfPage\":{\"@id\":\"https:\/\/www.tqazy.com\/?p=2077\"},\"wordCount\":322,\"commentCount\":0,\"publisher\":{\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e\"},\"image\":{\"@id\":\"https:\/\/www.tqazy.com\/?p=2077#primaryimage\"},\"thumbnailUrl\":\"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png\",\"keywords\":[\"mysql\",\"\u9762\u8bd5\u516b\u80a1\"],\"articleSection\":[\"\u9762\u8bd5\u516b\u80a1\"],\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"CommentAction\",\"name\":\"Comment\",\"target\":[\"https:\/\/www.tqazy.com\/?p=2077#respond\"]}]},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/www.tqazy.com\/?p=2077\",\"url\":\"https:\/\/www.tqazy.com\/?p=2077\",\"name\":\"\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517301 - \u57fa\u7840\u6838\u5fc3 | \u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2\",\"isPartOf\":{\"@id\":\"https:\/\/www.tqazy.com\/#website\"},\"primaryImageOfPage\":{\"@id\":\"https:\/\/www.tqazy.com\/?p=2077#primaryimage\"},\"image\":{\"@id\":\"https:\/\/www.tqazy.com\/?p=2077#primaryimage\"},\"thumbnailUrl\":\"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png\",\"datePublished\":\"2025-11-20T04:37:13+00:00\",\"dateModified\":\"2025-11-20T07:07:41+00:00\",\"breadcrumb\":{\"@id\":\"https:\/\/www.tqazy.com\/?p=2077#breadcrumb\"},\"inLanguage\":\"zh-Hans\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/www.tqazy.com\/?p=2077\"]}]},{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.tqazy.com\/?p=2077#primaryimage\",\"url\":\"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png\",\"contentUrl\":\"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png\"},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/www.tqazy.com\/?p=2077#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"name\":\"\u9996\u9875\",\"item\":\"https:\/\/www.tqazy.com\/\"},{\"@type\":\"ListItem\",\"position\":2,\"name\":\"\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517301 &#8211; \u57fa\u7840\u6838\u5fc3\"}]},{\"@type\":\"WebSite\",\"@id\":\"https:\/\/www.tqazy.com\/#website\",\"url\":\"https:\/\/www.tqazy.com\/\",\"name\":\"\u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2\",\"description\":\"\u5f53\u4e0b\uff0c\u5373\u662f\u672a\u6765\",\"publisher\":{\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e\"},\"alternateName\":\"TaoQi's Blog\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":{\"@type\":\"EntryPoint\",\"urlTemplate\":\"https:\/\/www.tqazy.com\/?s={search_term_string}\"},\"query-input\":{\"@type\":\"PropertyValueSpecification\",\"valueRequired\":true,\"valueName\":\"search_term_string\"}}],\"inLanguage\":\"zh-Hans\"},{\"@type\":[\"Person\",\"Organization\"],\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e\",\"name\":\"\u9676\u5176\",\"image\":{\"@type\":\"ImageObject\",\"inLanguage\":\"zh-Hans\",\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/image\/\",\"url\":\"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2024\/06\/20240604021741672.jpg\",\"contentUrl\":\"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2024\/06\/20240604021741672.jpg\",\"width\":940,\"height\":940,\"caption\":\"\u9676\u5176\"},\"logo\":{\"@id\":\"https:\/\/www.tqazy.com\/#\/schema\/person\/image\/\"},\"description\":\"\u4e00\u4e2a\u5f88\u61d2\u7684\u7a0b\u5e8f\u5458\",\"sameAs\":[\"https:\/\/www.tqazy.com\"],\"url\":\"https:\/\/www.tqazy.com\/?author=1\"}]}<\/script>\n<!-- \/ Yoast SEO plugin. -->","yoast_head_json":{"title":"\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517301 - \u57fa\u7840\u6838\u5fc3 | \u9676\u5176\u7684\u4e2a\u4eba\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.tqazy.com\/?p=2077","og_locale":"zh_CN","og_type":"article","og_title":"\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517301 - \u57fa\u7840\u6838\u5fc3 | \u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2","og_description":"\u6574\u4f53\u67b6\u6784\u3001\u6838\u5fc3\u7ec4\u4ef6\u3001\u5b58\u50a8\u5f15\u64ce\u3001InnoDB\u5b58\u50a8\u5f15\u64ce\u3001\u4e09\u5927\u8303\u5f0f\u548c\u53cd\u8303\u5f0f\u3001DDL\/DML\/DCL\/DQL\u3001\u6570\u636e\u5e93\u8868\u5b57\u6bb5\u7c7b\u578b\u3002\u672c\u6587\u4f1a\u6301\u7eed\u66f4\u65b0...","og_url":"https:\/\/www.tqazy.com\/?p=2077","og_site_name":"\u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2","article_published_time":"2025-11-20T04:37:13+00:00","article_modified_time":"2025-11-20T07:07:41+00:00","og_image":[{"url":"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png","type":"","width":"","height":""}],"author":"\u9676\u5176","twitter_card":"summary_large_image","twitter_misc":{"\u4f5c\u8005":"\u9676\u5176","\u9884\u8ba1\u9605\u8bfb\u65f6\u95f4":"5 \u5206"},"schema":{"@context":"https:\/\/schema.org","@graph":[{"@type":"Article","@id":"https:\/\/www.tqazy.com\/?p=2077#article","isPartOf":{"@id":"https:\/\/www.tqazy.com\/?p=2077"},"author":{"name":"\u9676\u5176","@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e"},"headline":"\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517301 &#8211; \u57fa\u7840\u6838\u5fc3","datePublished":"2025-11-20T04:37:13+00:00","dateModified":"2025-11-20T07:07:41+00:00","mainEntityOfPage":{"@id":"https:\/\/www.tqazy.com\/?p=2077"},"wordCount":322,"commentCount":0,"publisher":{"@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e"},"image":{"@id":"https:\/\/www.tqazy.com\/?p=2077#primaryimage"},"thumbnailUrl":"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png","keywords":["mysql","\u9762\u8bd5\u516b\u80a1"],"articleSection":["\u9762\u8bd5\u516b\u80a1"],"inLanguage":"zh-Hans","potentialAction":[{"@type":"CommentAction","name":"Comment","target":["https:\/\/www.tqazy.com\/?p=2077#respond"]}]},{"@type":"WebPage","@id":"https:\/\/www.tqazy.com\/?p=2077","url":"https:\/\/www.tqazy.com\/?p=2077","name":"\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517301 - \u57fa\u7840\u6838\u5fc3 | \u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2","isPartOf":{"@id":"https:\/\/www.tqazy.com\/#website"},"primaryImageOfPage":{"@id":"https:\/\/www.tqazy.com\/?p=2077#primaryimage"},"image":{"@id":"https:\/\/www.tqazy.com\/?p=2077#primaryimage"},"thumbnailUrl":"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png","datePublished":"2025-11-20T04:37:13+00:00","dateModified":"2025-11-20T07:07:41+00:00","breadcrumb":{"@id":"https:\/\/www.tqazy.com\/?p=2077#breadcrumb"},"inLanguage":"zh-Hans","potentialAction":[{"@type":"ReadAction","target":["https:\/\/www.tqazy.com\/?p=2077"]}]},{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.tqazy.com\/?p=2077#primaryimage","url":"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png","contentUrl":"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2025\/11\/20251117035316750.png"},{"@type":"BreadcrumbList","@id":"https:\/\/www.tqazy.com\/?p=2077#breadcrumb","itemListElement":[{"@type":"ListItem","position":1,"name":"\u9996\u9875","item":"https:\/\/www.tqazy.com\/"},{"@type":"ListItem","position":2,"name":"\u9762\u8bd5\u7b14\u8bb0\uff1aMySQL \u76f8\u517301 &#8211; \u57fa\u7840\u6838\u5fc3"}]},{"@type":"WebSite","@id":"https:\/\/www.tqazy.com\/#website","url":"https:\/\/www.tqazy.com\/","name":"\u9676\u5176\u7684\u4e2a\u4eba\u535a\u5ba2","description":"\u5f53\u4e0b\uff0c\u5373\u662f\u672a\u6765","publisher":{"@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e"},"alternateName":"TaoQi's Blog","potentialAction":[{"@type":"SearchAction","target":{"@type":"EntryPoint","urlTemplate":"https:\/\/www.tqazy.com\/?s={search_term_string}"},"query-input":{"@type":"PropertyValueSpecification","valueRequired":true,"valueName":"search_term_string"}}],"inLanguage":"zh-Hans"},{"@type":["Person","Organization"],"@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/b2e89d56e70f15c261012417c5ef2c4e","name":"\u9676\u5176","image":{"@type":"ImageObject","inLanguage":"zh-Hans","@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/image\/","url":"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2024\/06\/20240604021741672.jpg","contentUrl":"https:\/\/oss.tqazy.com\/wordpress\/autoFile\/2024\/06\/20240604021741672.jpg","width":940,"height":940,"caption":"\u9676\u5176"},"logo":{"@id":"https:\/\/www.tqazy.com\/#\/schema\/person\/image\/"},"description":"\u4e00\u4e2a\u5f88\u61d2\u7684\u7a0b\u5e8f\u5458","sameAs":["https:\/\/www.tqazy.com"],"url":"https:\/\/www.tqazy.com\/?author=1"}]}},"_links":{"self":[{"href":"https:\/\/www.tqazy.com\/index.php?rest_route=\/wp\/v2\/posts\/2077","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.tqazy.com\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.tqazy.com\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.tqazy.com\/index.php?rest_route=\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/www.tqazy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=2077"}],"version-history":[{"count":11,"href":"https:\/\/www.tqazy.com\/index.php?rest_route=\/wp\/v2\/posts\/2077\/revisions"}],"predecessor-version":[{"id":2111,"href":"https:\/\/www.tqazy.com\/index.php?rest_route=\/wp\/v2\/posts\/2077\/revisions\/2111"}],"wp:attachment":[{"href":"https:\/\/www.tqazy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=2077"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.tqazy.com\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=2077"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.tqazy.com\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=2077"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}