{"id":80828,"date":"2024-10-16T14:46:18","date_gmt":"2024-10-16T06:46:18","guid":{"rendered":"https:\/\/server.hk\/cnblog\/80828\/"},"modified":"2024-10-16T14:46:19","modified_gmt":"2024-10-16T06:46:19","slug":"mysql%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%90%84%e5%88%97%e9%a1%9e%e5%9e%8b%e7%9a%84%e5%8d%80%e5%88%a5","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/80828\/","title":{"rendered":"MySQL\u5b57\u7b26\u4e32\u5404\u5217\u985e\u578b\u7684\u5340\u5225"},"content":{"rendered":"<h1 id=\"mysql%e5%ad%97%e7%ac%a6%e4%b8%b2%e5%90%84%e5%88%97%e9%a1%9e%e5%9e%8b%e7%9a%84%e5%8d%80%e5%88%a5-nqgLAMLQdK\">MySQL\u5b57\u7b26\u4e32\u5404\u5217\u985e\u578b\u7684\u5340\u5225<\/h1>\n<p>\u5728\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\u4e2d\uff0cMySQL\u662f\u4e00\u500b\u5ee3\u6cdb\u4f7f\u7528\u7684\u958b\u6e90\u6578\u64da\u5eab\uff0c\u7279\u5225\u662f\u5728Web\u61c9\u7528\u7a0b\u5e8f\u4e2d\u3002MySQL\u652f\u6301\u591a\u7a2e\u6578\u64da\u985e\u578b\uff0c\u5176\u4e2d\u5b57\u7b26\u4e32\u985e\u578b\u662f\u6700\u5e38\u7528\u7684\u985e\u578b\u4e4b\u4e00\u3002\u4e86\u89e3\u9019\u4e9b\u5b57\u7b26\u4e32\u985e\u578b\u7684\u5340\u5225\u5c0d\u65bc\u8a2d\u8a08\u9ad8\u6548\u7684\u6578\u64da\u5eab\u7d50\u69cb\u81f3\u95dc\u91cd\u8981\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eMySQL\u4e2d\u7684\u5404\u7a2e\u5b57\u7b26\u4e32\u985e\u578b\u53ca\u5176\u7279\u9ede\u3002<\/p>\n<h2 id=\"1-%e5%ad%97%e7%ac%a6%e4%b8%b2%e9%a1%9e%e5%9e%8b%e6%a6%82%e8%bf%b0-nqgLAMLQdK\">1. \u5b57\u7b26\u4e32\u985e\u578b\u6982\u8ff0<\/h2>\n<p>MySQL\u4e2d\u7684\u5b57\u7b26\u4e32\u985e\u578b\u4e3b\u8981\u5206\u70ba\u4ee5\u4e0b\u5e7e\u985e\uff1a<\/p>\n<ul>\n<li><strong>CHAR<\/strong><\/li>\n<li><strong>VARCHAR<\/strong><\/li>\n<li><strong>TINYTEXT<\/strong><\/li>\n<li><strong>TEXT<\/strong><\/li>\n<li><strong>MEDIUMTEXT<\/strong><\/li>\n<li><strong>LONGTEXT<\/strong><\/li>\n<li><strong>BINARY<\/strong><\/li>\n<li><strong>VARBINARY<\/strong><\/li>\n<li><strong>TINYBLOB<\/strong><\/li>\n<li><strong>BLOB<\/strong><\/li>\n<li><strong>MEDIUMBLOB<\/strong><\/li>\n<li><strong>LONGBLOB<\/strong><\/li>\n<\/ul>\n<h2 id=\"2-%e5%90%84%e5%ad%97%e7%ac%a6%e4%b8%b2%e9%a1%9e%e5%9e%8b%e7%9a%84%e8%a9%b3%e7%b4%b0%e4%bb%8b%e7%b4%b9-nqgLAMLQdK\">2. \u5404\u5b57\u7b26\u4e32\u985e\u578b\u7684\u8a73\u7d30\u4ecb\u7d39<\/h2>\n<h3 id=\"2-1-char-nqgLAMLQdK\">2.1 CHAR<\/h3>\n<p>CHAR\u662f\u4e00\u7a2e\u56fa\u5b9a\u9577\u5ea6\u7684\u5b57\u7b26\u4e32\u985e\u578b\u3002\u7576\u5b58\u5132\u7684\u5b57\u7b26\u4e32\u9577\u5ea6\u5c0f\u65bc\u5b9a\u7fa9\u7684\u9577\u5ea6\u6642\uff0cMySQL\u6703\u81ea\u52d5\u7528\u7a7a\u683c\u586b\u5145\u3002\u9019\u4f7f\u5f97CHAR\u5728\u8655\u7406\u56fa\u5b9a\u9577\u5ea6\u7684\u6578\u64da\u6642\u975e\u5e38\u9ad8\u6548\u3002<\/p>\n<pre><code>CREATE TABLE example_char (\n    id INT,\n    name CHAR(10)\n);<\/code><\/pre>\n<h3 id=\"2-2-varchar-nqgLAMLQdK\">2.2 VARCHAR<\/h3>\n<p>VARCHAR\u662f\u4e00\u7a2e\u53ef\u8b8a\u9577\u5ea6\u7684\u5b57\u7b26\u4e32\u985e\u578b\uff0c\u9069\u5408\u5b58\u5132\u9577\u5ea6\u4e0d\u4e00\u7684\u5b57\u7b26\u4e32\u3002\u8207CHAR\u4e0d\u540c\uff0cVARCHAR\u4e0d\u6703\u586b\u5145\u7a7a\u683c\uff0c\u9019\u4f7f\u5f97\u5b83\u5728\u5b58\u5132\u8b8a\u9577\u5b57\u7b26\u4e32\u6642\u66f4\u70ba\u9ad8\u6548\u3002<\/p>\n<pre><code>CREATE TABLE example_varchar (\n    id INT,\n    name VARCHAR(255)\n);<\/code><\/pre>\n<h3 id=\"2-3-tinytext-text-mediumtext-longtext-nqgLAMLQdK\">2.3 TINYTEXT, TEXT, MEDIUMTEXT, LONGTEXT<\/h3>\n<p>\u9019\u4e9b\u985e\u578b\u7528\u65bc\u5b58\u5132\u9577\u6587\u672c\u6578\u64da\u3002\u5b83\u5011\u7684\u4e3b\u8981\u5340\u5225\u5728\u65bc\u53ef\u4ee5\u5b58\u5132\u7684\u5b57\u7b26\u6578\u91cf\uff1a<\/p>\n<ul>\n<li><strong>TINYTEXT<\/strong>: \u6700\u591a\u53ef\u5b58\u5132255\u5b57\u5143\u3002<\/li>\n<li><strong>TEXT<\/strong>: \u6700\u591a\u53ef\u5b58\u513265,535\u5b57\u5143\u3002<\/li>\n<li><strong>MEDIUMTEXT<\/strong>: \u6700\u591a\u53ef\u5b58\u513216,777,215\u5b57\u5143\u3002<\/li>\n<li><strong>LONGTEXT<\/strong>: \u6700\u591a\u53ef\u5b58\u51324,294,967,295\u5b57\u5143\u3002<\/li>\n<\/ul>\n<h3 id=\"2-4-binary%e5%92%8cvarbinary-nqgLAMLQdK\">2.4 BINARY\u548cVARBINARY<\/h3>\n<p>BINARY\u548cVARBINARY\u985e\u578b\u7528\u65bc\u5b58\u5132\u4e8c\u9032\u5236\u6578\u64da\u3002BINARY\u662f\u56fa\u5b9a\u9577\u5ea6\u7684\uff0c\u800cVARBINARY\u662f\u53ef\u8b8a\u9577\u5ea6\u7684\u3002\u9019\u4e9b\u985e\u578b\u9069\u5408\u5b58\u5132\u5716\u50cf\u3001\u97f3\u983b\u7b49\u4e8c\u9032\u5236\u6587\u4ef6\u3002<\/p>\n<pre><code>CREATE TABLE example_binary (\n    id INT,\n    data BINARY(16)\n);<\/code><\/pre>\n<h3 id=\"2-5-blob-tinyblob-mediumblob-longblob-nqgLAMLQdK\">2.5 BLOB, TINYBLOB, MEDIUMBLOB, LONGBLOB<\/h3>\n<p>\u9019\u4e9b\u985e\u578b\u7528\u65bc\u5b58\u5132\u4e8c\u9032\u5236\u5927\u5c0d\u8c61\uff08BLOB\uff09\u3002\u5b83\u5011\u7684\u5b58\u5132\u5bb9\u91cf\u8207TEXT\u985e\u4f3c\uff1a<\/p>\n<ul>\n<li><strong>TINYBLOB<\/strong>: \u6700\u591a\u53ef\u5b58\u5132255\u5b57\u5143\u3002<\/li>\n<li><strong>BLOB<\/strong>: \u6700\u591a\u53ef\u5b58\u513265,535\u5b57\u5143\u3002<\/li>\n<li><strong>MEDIUMBLOB<\/strong>: \u6700\u591a\u53ef\u5b58\u513216,777,215\u5b57\u5143\u3002<\/li>\n<li><strong>LONGBLOB<\/strong>: \u6700\u591a\u53ef\u5b58\u51324,294,967,295\u5b57\u5143\u3002<\/li>\n<\/ul>\n<h2 id=\"3-%e9%81%b8%e6%93%87%e5%90%88%e9%81%a9%e7%9a%84%e5%ad%97%e7%ac%a6%e4%b8%b2%e9%a1%9e%e5%9e%8b-nqgLAMLQdK\">3. \u9078\u64c7\u5408\u9069\u7684\u5b57\u7b26\u4e32\u985e\u578b<\/h2>\n<p>\u5728\u9078\u64c7\u5b57\u7b26\u4e32\u985e\u578b\u6642\uff0c\u958b\u767c\u8005\u61c9\u8003\u616e\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u6578\u64da\u7684\u9577\u5ea6\uff1a\u5982\u679c\u6578\u64da\u9577\u5ea6\u56fa\u5b9a\uff0c\u4f7f\u7528CHAR\uff1b\u5982\u679c\u9577\u5ea6\u4e0d\u4e00\uff0c\u4f7f\u7528VARCHAR\u3002<\/li>\n<li>\u6578\u64da\u7684\u6027\u8cea\uff1a\u5c0d\u65bc\u9577\u6587\u672c\uff0c\u9078\u64c7TEXT\u985e\u578b\uff1b\u5c0d\u65bc\u4e8c\u9032\u5236\u6578\u64da\uff0c\u9078\u64c7BLOB\u985e\u578b\u3002<\/li>\n<li>\u6027\u80fd\u9700\u6c42\uff1aCHAR\u5728\u56fa\u5b9a\u9577\u5ea6\u7684\u60c5\u6cc1\u4e0b\u6027\u80fd\u66f4\u4f73\uff0c\u800cVARCHAR\u5728\u8b8a\u9577\u6578\u64da\u4e2d\u66f4\u70ba\u9ad8\u6548\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-nqgLAMLQdK\">\u7e3d\u7d50<\/h2>\n<p>\u4e86\u89e3MySQL\u4e2d\u7684\u5404\u7a2e\u5b57\u7b26\u4e32\u985e\u578b\u53ca\u5176\u7279\u9ede\u5c0d\u65bc\u8a2d\u8a08\u9ad8\u6548\u7684\u6578\u64da\u5eab\u7d50\u69cb\u81f3\u95dc\u91cd\u8981\u3002\u9078\u64c7\u5408\u9069\u7684\u5b57\u7b26\u4e32\u985e\u578b\u53ef\u4ee5\u63d0\u9ad8\u6578\u64da\u5eab\u7684\u6027\u80fd\u548c\u5b58\u5132\u6548\u7387\u3002\u7121\u8ad6\u662f\u4f7f\u7528 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u9084\u662f\u5176\u4ed6\u670d\u52d9\uff0c\u6b63\u78ba\u7684\u6578\u64da\u985e\u578b\u9078\u64c7\u90fd\u662f\u6210\u529f\u7684\u95dc\u9375\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u4e86\u89e3MySQL\u4e2d\u4e0d\u540c\u5b57\u7b26\u4e32\u5217\u7c7b\u578b\u7684\u7279\u70b9\u4e0e\u533a\u522b\uff0c\u5305\u62ecCHAR\u3001VARCHAR\u3001TEXT\u7b49\uff0c\u5e2e\u52a9\u4f18\u5316\u6570\u636e\u5e93\u8bbe\u8ba1\u4e0e\u6027\u80fd\u3002<\/p>\n","protected":false},"author":0,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[101],"tags":[],"class_list":["post-80828","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/80828","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/types\/post"}],"replies":[{"embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/comments?post=80828"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/80828\/revisions"}],"predecessor-version":[{"id":80829,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/80828\/revisions\/80829"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=80828"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=80828"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=80828"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}