{"id":184,"date":"2011-02-02T00:15:40","date_gmt":"2011-02-01T16:15:40","guid":{"rendered":"http:\/\/www.youthtribe.com\/?p=184"},"modified":"2011-02-02T00:15:40","modified_gmt":"2011-02-01T16:15:40","slug":"mysql%e6%95%b0%e6%8d%ae%e5%ba%93%e7%9a%84%e6%95%b0%e6%8d%ae%e7%b1%bb%e5%9e%8b","status":"publish","type":"post","link":"http:\/\/www.youthtribe.com\/archives\/184","title":{"rendered":"mysql\u6570\u636e\u5e93\u7684\u6570\u636e\u7c7b\u578b"},"content":{"rendered":"

MySQL\u6570\u636e\u5e93\u7684\u8868\u662f\u4e00\u4e2a\u4e8c\u7ef4\u8868\uff0c\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u6570\u636e\u5217\u6784\u6210\u3002
\n\u6bcf\u4e2a\u6570\u636e\u5217\u90fd\u6709\u5b83\u7684\u7279\u5b9a\u7c7b\u578b\uff0c\u8be5\u7c7b\u578b\u51b3\u5b9a\u4e86MySQL\u5982\u4f55\u770b\u5f85\u8be5\u5217\u6570\u636e\uff0c\u6211\u4eec\u53ef\u4ee5\u628a\u6574\u578b\u6570\u503c\u5b58\u653e\u5230\u5b57\u7b26\u7c7b\u578b\u7684\u5217\u4e2d\uff0cMySQL\u5219\u4f1a\u628a\u5b83\u770b\u6210\u5b57\u7b26\u4e32\u6765\u5904\u7406\u3002
\nMySQL\u4e2d\u7684\u5217\u7c7b\u578b\u6709\u4e09\u79cd\uff1a\u6570\u503c\u7c7b\u3001\u5b57\u7b26\u4e32\u7c7b\u548c\u65e5\u671f\/\u65f6\u95f4\u7c7b\u3002
\n\u4ece\u5927\u7c7b\u6765\u770b\u5217\u7c7b\u578b\u548c\u6570\u503c\u7c7b\u578b\u4e00\u6837\uff0c\u90fd\u662f\u53ea\u6709\u4e09\u79cd\u3002\u4f46\u6bcf\u79cd\u5217\u7c7b\u578b\u90fd\u8fd8\u53ef\u7ec6\u5206\u3002
\n\u4e0b\u9762\u5bf9\u5404\u79cd\u5217\u7c7b\u578b\u8fdb\u884c\u8be6\u7ec6\u4ecb\u7ecd\u3002 <\/p>\n

\u6570\u503c\u7c7b\u7684\u6570\u636e\u5217\u7c7b\u578b
\n\u6570\u503c\u578b\u7684\u5217\u7c7b\u578b\u5305\u62ec\u6574\u578b\u548c\u6d6e\u70b9\u578b\u4e24\u5927\u7c7b\u3002 <\/p>\n

TINYINT\uff1a1\u5b57\u8282 \u975e\u5e38\u5c0f\u7684\u6b63\u6574\u6570\uff0c\u5e26\u7b26\u53f7\uff1a-128~127\uff0c\u4e0d\u5e26\u7b26\u53f7\uff1a0~255
\nSMALLINT\uff1a2\u5b57\u8282 \u5c0f\u6574\u6570\uff0c\u5e26\u7b26\u53f7\uff1a-32768~32767\uff0c\u4e0d\u5e26\u7b26\u53f7\uff1a0~65535
\nMEDIUMINT\uff1a3\u5b57\u8282 \u4e2d\u7b49\u5927\u5c0f\u7684\u6574\u6570\uff0c\u5e26\u7b26\u53f7\uff1a-8388608~8388607\uff0c\u4e0d\u5e26\u7b26\u53f7\uff1a0~16777215
\nINT\uff1a4\u5b57\u8282 \u6807\u51c6\u6574\u6570\uff0c\u5e26\u7b26\u53f7\uff1a-2147483648~2147483647\uff0c\u4e0d\u5e26\u7b26\u53f7\uff1a0~4294967295
\nBIGINT\uff1a8\u5b57\u8282 \u5927\u6574\u6570\uff0c\u5e26\u7b26\u53f7\uff1a-9223372036854775808~9233372036854775807\uff0c\u4e0d\u5e26\u7b26\u53f7\uff1a0~18446744073709551615
\nFLOAT\uff1a4\u5b57\u8282 \u5355\u7cbe\u5ea6\u6d6e\u70b9\u6570\uff0c\u6700\u5c0f\u975e\u96f6\u503c\uff1a+-1.175494351E-38\uff0c\u6700\u5927\u975e\u96f6\u503c\uff1a+-3.402823466E+38
\nDOUBLE\uff1a8\u5b57\u8282 \u53cc\u7cbe\u5ea6\u6d6e\u70b9\u6570\uff0c\u6700\u5c0f\u975e\u96f6\u503c\uff1a+-2.2250738585072014E-308\uff0c\u6700\u5927\u975e\u96f6\u503c\uff1a+-1.7976931348623157E+308
\nDECIMAL\uff1aM+2\u5b57\u8282 \u4ee5\u5b57\u7b26\u4e32\u5f62\u5f0f\u8868\u793a\u7684\u6d6e\u70b9\u6570\uff0c\u5b83\u7684\u53d6\u503c\u8303\u56f4\u53ef\u53d8\uff0c\u7531M\u548cD\u7684\u503c\u51b3\u5b9a\u3002 <\/p>\n

\u6574\u578b\u6570\u636e\u5217\u7c7b\u578b <\/p>\n

MySQL\u6709\u4e94\u79cd\u6574\u578b\u6570\u636e\u5217\u7c7b\u578b\uff0c\u5373TINYINT\uff0cSMALLINT\uff0cMEDIUMINT\uff0cINT\u548cBIGINT\u3002\u5b83\u4eec\u4e4b\u95f4\u7684\u533a\u522b\u662f\u53d6\u503c\u8303\u56f4\u4e0d\u540c\uff0c\u5b58\u50a8\u7a7a\u95f4\u4e5f\u5404\u4e0d\u76f8\u540c\u3002
\n\u5728\u6574\u578b\u6570\u636e\u5217\u540e\u52a0\u4e0aUNSIGNED\u5c5e\u6027\u53ef\u4ee5\u7981\u6b62\u8d1f\u6570\uff0c\u53d6\u503c\u4ece0\u5f00\u59cb\u3002 <\/p>\n

\u58f0\u660e\u6574\u578b\u6570\u636e\u5217\u65f6\uff0c\u6211\u4eec\u53ef\u4ee5\u4e3a\u5b83\u6307\u5b9a\u4e2a\u663e\u793a\u5bbd\u5ea6M(1~255)\uff0c\u5982INT(5)\uff0c\u6307\u5b9a\u663e\u793a\u5bbd\u5ea6\u4e3a5\u4e2a\u5b57\u7b26,\u5982\u679c\u6ca1\u6709\u7ed9\u5b83\u6307\u5b9a\u663e\u793a\u5bbd\u5ea6\uff0cMySQL\u4f1a\u4e3a\u5b83\u6307\u5b9a\u4e00\u4e2a\u9ed8\u8ba4\u503c\u3002\u663e\u793a\u5bbd\u5ea6\u53ea\u7528\u4e8e\u663e\u793a\uff0c\u5e76\u4e0d\u80fd\u9650\u5236\u53d6\u503c\u8303\u56f4\u548c\u5360\u7528\u7a7a\u95f4\uff0c\u5982\uff1aINT(3)\u4f1a\u5360\u75284\u4e2a\u5b57\u8282\u7684\u5b58\u50a8\u7a7a\u95f4\uff0c\u5e76\u4e14\u5141\u8bb8\u7684\u6700\u5927\u503c\u4e5f\u4e0d\u4f1a\u662f999,\u800c\u662f INT\u6574\u578b\u6240\u5141\u8bb8\u7684\u6700\u5927\u503c\u3002
\n\u4f8b\u5982\u5982\u679cint\u7684\u503c\u4e3a10
\nint\uff0810\uff09\u663e\u793a\u7ed3\u679c\u4e3a0000000010
\nint\uff083\uff09\u663e\u793a\u7ed3\u679c\u4e3a010
\n\u5c31\u662f\u663e\u793a\u7684\u957f\u5ea6\u4e0d\u4e00\u6837\u800c\u5df2 \u90fd\u662f\u5360\u7528\u56db\u4e2a\u5b57\u8282\u7684\u7a7a\u95f4<\/p>\n

\u6d6e\u70b9\u578b\u6570\u636e\u5217\u7c7b\u578b <\/p>\n

MySQL\u6709\u4e09\u79cd\u6d6e\u70b9\u578b\u6570\u636e\u5217\u7c7b\u578b\uff0c\u5206\u522b\u662f\uff1aFLOAT\uff0cDOUBLE\u548cDECIMAL\u3002
\n\u6d6e\u70b9\u7c7b\u6570\u636e\u7c7b\u578b\u6709\u4e00\u4e2a\u6700\u5927\u53ef\u8868\u793a\u503c\u548c\u4e00\u4e2a\u6700\u5c0f\u975e\u96f6\u53ef\u8868\u793a\u503c\uff0c\u6700\u5c0f\u975e\u96f6\u53ef\u8868\u793a\u503c\u51b3\u5b9a\u4e86\u8be5\u7c7b\u578b\u7684\u7cbe\u786e\u5ea6\u3002 <\/p>\n

MySQL 4.0.2\u7248\u4e4b\u540e\uff0cFLOAT\u548cDOUBLE\u90fd\u53ef\u4ee5\u6307\u5b9aUNSIGNED\u5c5e\u6027\u3002\u5f53\u6307\u5b9a\u8be5\u5c5e\u6027\u65f6\uff0c\u53d6\u503c\u8303\u56f4\u4e0d\u5e73\u79fb\u5230\u6b63\u6570\u533a\u95f4\uff0c\u800c\u53ea\u662f\u7b80\u5355\u5730\u628a\u6d6e\u70b9\u7c7b\u578b\u7684\u8d1f\u6570\u90e8\u4efd\u53bb\u6389\u3002 <\/p>\n

\u6d6e\u70b9\u7c7b\u578b\u4e5f\u6709M(1~255)\u548cD(1~30\uff0c\u4e14\u4e0d\u80fd\u5927\u4e8eM-2)\u3002\u5206\u522b\u8868\u793a\u663e\u793a\u5bbd\u5ea6\u548c\u5c0f\u6570\u4f4d\u6570\u3002M\u548cD\u5728FLOAT\u548cDOUBLE\u4e2d\u662f\u53ef\u9009\u7684\uff0c\u9ed8\u8ba4\uff0c\u5f53 MySQL\u7248\u672c\u5927\u4e8e3.23.6\u65f6\uff0cFLOAT\u548cDOUBLE\u7c7b\u578b\u5c06\u88ab\u4fdd\u5b58\u4e3a\u786c\u4ef6\u6240\u652f\u6301\u7684\u6700\u5927\u7cbe\u5ea6\u3002DECIMAL\u7684M\u548cD\u503c\u5728MySQL3.23.6\u540e\u53ef\u9009\uff0c\u9ed8\u8ba4D\u503c\u4e3a0,M\u503c\u4e3a10\u3002 <\/p>\n

\u5982\u4f55\u9009\u62e9\u6570\u503c\u7c7b\u6570\u636e\u5217\u7c7b\u578b\uff1f <\/p>\n

\u4e3a\u4e86\u8282\u7701\u5b58\u50a8\u7a7a\u95f4\u548c\u63d0\u9ad8\u6570\u636e\u5e93\u5904\u7406\u6548\u7387\uff0c\u6211\u4eec\u5e94\u6839\u636e\u5e94\u7528\u6570\u636e\u7684\u53d6\u503c\u8303\u56f4\u6765\u9009\u62e9\u4e00\u4e2a\u6700\u9002\u5408\u7684\u6570\u636e\u5217\u7c7b\u578b\u3002\u5982\u679c\u628a\u4e00\u4e2a\u8d85\u51fa\u6570\u636e\u5217\u53d6\u503c\u8303\u56f4\u7684\u6570\u5b58\u5165\u8be5\u5217\uff0c\u5219 MySQL\u5c31\u4f1a\u622a\u77ed\u8be5\u503c\uff0c\u5982\uff1a\u6211\u4eec\u628a99999\u5b58\u5165SMALLINT(3)\u6570\u636e\u5217\u91cc\uff0c\u56e0\u4e3aSMALLINT(3)\u7684\u53d6\u503c\u8303\u56f4\u662f-32768~32767\uff0c\u6240\u4ee5\u5c31\u4f1a\u88ab\u622a\u77ed\u621032767\u5b58\u50a8\u3002\u663e\u793a\u5bbd\u5ea63\u4e0d\u4f1a\u5f71\u54cd\u6570\u503c\u7684\u5b58\u50a8\u3002\u53ea\u5f71\u54cd\u663e\u793a\u3002 <\/p>\n

\u5bf9\u4e8e\u6d6e\u70b9\u6570\u636e\u5217\uff0c\u5b58\u5165\u7684\u6570\u503c\u4f1a\u88ab\u8be5\u5217\u5b9a\u4e49\u7684\u5c0f\u6570\u4f4d\u8fdb\u884c\u56db\u820d\u4e94\u5165\u3002\u5982\u628a\u4e00\u4e2a1.234\u5b58\u5165FLOAT(6.1)\u6570\u636e\u5217\u4e2d\uff0c\u7ed3\u679c\u662f1.2\u3002 <\/p>\n

DECIMAL\u4e0eFLOAT\u548cDOUBLE\u7684\u533a\u522b\u662f\uff1aDECIMAL\u7c7b\u578b\u7684\u503c\u662f\u4ee5\u5b57\u7b26\u4e32\u7684\u5f62\u5f0f\u88ab\u50a8\u5b58\u8d77\u6765\u7684\uff0c\u5b83\u7684\u5c0f\u6570\u4f4d\u6570\u662f\u56fa\u5b9a\u7684\u3002\u5b83\u7684\u4f18\u70b9\u662f\uff0c\u4e0d\u4f1a\u8c61 FLOAT\u548cDOUBLE\u7c7b\u578b\u6570\u636e\u5217\u90a3\u6837\u8fdb\u884c\u56db\u820d\u4e94\u5165\u800c\u4ea7\u751f\u8bef\u5dee\uff0c\u6240\u4ee5\u5f88\u9002\u5408\u7528\u4e8e\u8d22\u52a1\u8ba1\u7b97\uff1b\u800c\u5b83\u7684\u7f3a\u70b9\u662f\uff1a\u7531\u4e8e\u5b83\u7684\u5b58\u50a8\u683c\u5f0f\u4e0d\u540c\uff0cCPU\u4e0d\u80fd\u5bf9\u5b83\u8fdb\u884c\u76f4\u63a5\u8fd0\u7b97\uff0c\u4ece\u800c\u5f71\u54cd\u8fd0\u7b97\u6548\u7387\u3002DECIMAL(M\uff0cD)\u603b\u5171\u8981\u5360\u7528M+2\u4e2a\u5b57\u8282\u3002 <\/p>\n

\u6570\u503c\u7c7b\u6570\u636e\u5217\u7684\u5c5e\u6027 <\/p>\n

ZEROFILL\u5c5e\u6027\u9002\u7528\u4e8e\u6240\u6709\u6570\u503c\u7c7b\u6570\u636e\u5217\u7c7b\u578b\uff0c\u4f5c\u7528\u662f\uff0c\u5982\u679c\u6570\u503c\u7684\u5bbd\u5ea6\u5c0f\u4e8e\u5b9a\u4e49\u7684\u663e\u793a\u5bbd\u5ea6\uff0c\u5219\u5728\u6570\u503c\u524d\u586b\u51450\u3002
\nUNSIGNED\u5c5e\u6027\u4e0d\u5141\u8bb8\u6570\u636e\u5217\u51fa\u73b0\u8d1f\u6570\u3002
\nAUTO_INCREMENT\u5c5e\u6027\u53ef\u751f\u6210\u72ec\u4e00\u65e0\u4e8c\u7684\u6570\u5b57\u5e8f\u5217\u3002\u53ea\u5bf9\u6574\u6570\u7c7b\u7684\u6570\u636e\u5217\u6709\u6548\u3002
\nNULL\u548cNOT NULL\u5c5e\u6027\u8bbe\u7f6e\u6570\u636e\u5217\u662f\u5426\u53ef\u4e3a\u7a7a\u3002
\nDEFAULT\u5c5e\u6027\u53ef\u4e3a\u6570\u636e\u5217\u6307\u5b9a\u9ed8\u8ba4\u503c\u3002 <\/p>\n

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ <\/p>\n

\u5b57\u7b26\u4e32\u7c7b\u6570\u636e\u5217\u7c7b\u578b <\/p>\n

\u5b57\u7b26\u4e32\u53ef\u4ee5\u7528\u6765\u8868\u793a\u4efb\u4f55\u4e00\u79cd\u503c\uff0c\u6240\u4ee5\u5b83\u662f\u6700\u57fa\u672c\u7684\u7c7b\u578b\u4e4b\u4e00\u3002
\n\u6211\u4eec\u53ef\u4ee5\u7528\u5b57\u7b26\u4e32\u7c7b\u578b\u6765\u5b58\u50a8\u56fe\u8c61\u6216\u58f0\u97f3\u4e4b\u7c7b\u7684\u4e8c\u8fdb\u5236\u6570\u636e\uff0c\u4e5f\u53ef\u5b58\u50a8\u7528gzip\u538b\u7f29\u7684\u6570\u636e\u3002
\n\u4e0b\u8868\u4ecb\u7ecd\u4e86\u5404\u79cd\u5b57\u7b26\u4e32\u7c7b\u578b\uff1a <\/p>\n

CHAR[(M)] M\u5b57\u8282 M\u5b57\u8282
\nVARCHAR[(M)] M\u5b57\u8282 L+1\u5b57\u8282
\nTINYBLOD\uff0cTINYTEXT 2^8-1\u5b57\u8282 L+1\u5b57\u8282
\nBLOB\uff0cTEXT 2^16-1\u5b57\u8282 L+2
\nMEDIUMBLOB\uff0cMEDIUMTEXT 2^24-1\u5b57\u8282 L+3
\nLONGBLOB\uff0cLONGTEXT 2^32-1\u5b57\u8282 L+4
\nENUM(‘value1′,’value2’,…) 65535\u4e2a\u6210\u5458 1\u62162\u5b57\u8282
\nSET(‘value1′,’value2’,…) 64\u4e2a\u6210\u5458 1,2,3,4\u62168\u5b57\u8282 <\/p>\n

L+1\u3001L+2\u662f\u8868\u793a\u6570\u636e\u5217\u662f\u53ef\u53d8\u957f\u5ea6\u7684\uff0c\u5b83\u5360\u7528\u7684\u7a7a\u95f4\u4f1a\u6839\u636e\u6570\u636e\u884c\u7684\u589e\u51cf\u9762\u5219\u6539\u53d8\u3002\u6570\u636e\u884c\u7684\u603b\u957f\u5ea6\u53d6\u51b3\u4e8e\u5b58\u653e\u5728\u8fd9\u4e9b\u6570\u636e\u5217\u91cc\u7684\u6570\u636e\u503c\u7684\u957f\u5ea6\u3002L+1\u6216 L+2\u91cc\u591a\u51fa\u6765\u7684\u5b57\u8282\u662f\u7528\u6765\u4fdd\u5b58\u6570\u636e\u503c\u7684\u957f\u5ea6\u7684\u3002\u5728\u5bf9\u957f\u5ea6\u53ef\u53d8\u7684\u6570\u636e\u8fdb\u884c\u5904\u7406\u65f6\uff0cMySQL\u8981\u628a\u6570\u636e\u5185\u5bb9\u548c\u6570\u636e\u957f\u5ea6\u90fd\u4fdd\u5b58\u8d77\u6765\u3002 <\/p>\n

\u5982\u679c\u628a\u8d85\u51fa\u5b57\u7b26\u4e32\u6700\u5927\u957f\u5ea6\u7684\u6570\u636e\u653e\u5230\u5b57\u7b26\u7c7b\u6570\u636e\u5217\u4e2d\uff0cMySQL\u4f1a\u81ea\u52a8\u8fdb\u884c\u622a\u77ed\u5904\u7406\u3002 <\/p>\n

ENUM\u548cSET\u7c7b\u578b\u7684\u6570\u636e\u5217\u5b9a\u4e49\u91cc\u6709\u4e00\u4e2a\u5217\u8868\uff0c\u5217\u8868\u91cc\u7684\u5143\u7d20\u5c31\u662f\u8be5\u6570\u636e\u5217\u7684\u5408\u6cd5\u53d6\u503c\u3002\u5982\u679c\u8bd5\u56fe\u628a\u4e00\u4e2a\u6ca1\u6709\u5728\u5217\u8868\u91cc\u7684\u503c\u653e\u5230\u6570\u636e\u5217\u91cc\uff0c\u5b83\u4f1a\u88ab\u8f6c\u6362\u4e3a\u7a7a\u5b57\u7b26\u4e32(\u201c\u201d)\u3002 <\/p>\n

\u5b57\u7b26\u4e32\u7c7b\u578b\u7684\u503c\u88ab\u4fdd\u5b58\u4e3a\u4e00\u7ec4\u8fde\u7eed\u7684\u5b57\u8282\u5e8f\u5217\uff0c\u5e76\u4f1a\u6839\u636e\u5b83\u4eec\u5bb9\u7eb3\u7684\u662f\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u8fd8\u662f\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u800c\u88ab\u533a\u522b\u5bf9\u5f85\u4e3a\u5b57\u8282\u6216\u8005\u5b57\u7b26\uff1a <\/p>\n

\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u88ab\u89c6\u4e3a\u4e00\u4e2a\u8fde\u7eed\u7684\u5b57\u8282\u5e8f\u5217\uff0c\u4e0e\u5b57\u7b26\u96c6\u65e0\u5173\u3002MySQL\u628aBLOB\u6570\u636e\u5217\u548c\u5e26BINARY\u5c5e\u6027\u7684CHAR\u548cVARCHAR\u6570\u636e\u5217\u91cc\u7684\u6570\u636e\u5f53\u4f5c\u4e8c\u8fdb\u5236\u503c\u3002 <\/p>\n

\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u88ab\u89c6\u4e3a\u4e00\u4e2a\u8fde\u7eed\u6392\u5217\u7684\u5b57\u7b26\u5e8f\u5217\u3002\u4e0e\u5b57\u7b26\u96c6\u6709\u5173\u3002MySQL\u628aTEXT\u5217\u4e0e\u4e0d\u5e26BINARY\u5c5e\u6027\u7684CHAR\u548cVARCHAR\u6570\u636e\u5217\u91cc\u7684\u6570\u636e\u5f53\u4f5c\u4e8c\u8fdb\u5236\u503c\u5bf9\u5f85\u3002 <\/p>\n

\u5728MySQL4.1\u4ee5\u540e\u7684\u7248\u672c\u4e2d\uff0c\u4e0d\u540c\u7684\u6570\u636e\u5217\u53ef\u4ee5\u4f7f\u7528\u4e0d\u540c\u7684\u5b57\u7b26\u96c6\u3002\u5728MySQL4.1\u7248\u672c\u4ee5\u524d\uff0cMySQL\u7528\u670d\u52a1\u5668\u7684\u5b57\u7b26\u96c6\u4f5c\u4e3a\u9ed8\u8ba4\u5b57\u7b26\u96c6\u3002 <\/p>\n

\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0c\u5373\u6211\u4eec\u901a\u5e38\u6240\u8bf4\u7684\u5b57\u7b26\u4e32\uff0c\u662f\u6309\u5b57\u7b26\u5728\u5b57\u7b26\u96c6\u4e2d\u5148\u540e\u6b21\u5e8f\u8fdb\u884c\u6bd4\u8f83\u548c\u6392\u5e8f\u7684\u3002\u800c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u56e0\u4e3a\u4e0e\u5b57\u7b26\u96c6\u65e0\u5173\uff0c\u6240\u4ee5\u4e0d\u4ee5\u5b57\u7b26\u987a\u5e8f\u6392\u5e8f\uff0c\u800c\u662f\u4ee5\u5b57\u8282\u7684\u4e8c\u8fdb\u5236\u503c\u4f5c\u4e3a\u6bd4\u8f83\u548c\u6392\u5e8f\u7684\u4f9d\u636e\u3002\u4e0b\u9762\u4ecb\u7ecd\u4e24\u79cd\u5b57\u7b26\u4e32\u7684\u6bd4\u8f83\u65b9\u5f0f\uff1a <\/p>\n

\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u6bd4\u8f83\u65b9\u5f0f\u662f\u4e00\u4e2a\u5b57\u8282\u4e00\u4e2a\u5b57\u8282\u8fdb\u884c\u7684\uff0c\u6bd4\u8f83\u7684\u4f9d\u636e\u662f\u4e24\u4e2a\u5b57\u8282\u7684\u4e8c\u8fdb\u5236\u503c\u3002\u4e5f\u5c31\u662f\u8bf4\u5b83\u662f\u533a\u5206\u5927\u5c0f\u5199\u7684\uff0c\u56e0\u4e3a\u540c\u4e00\u4e2a\u5b57\u6bcd\u7684\u5927\u5c0f\u5199\u7684\u6570\u503c\u7f16\u7801\u662f\u4e0d\u4e00\u6837\u7684\u3002 <\/p>\n

\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u6bd4\u8f83\u65b9\u5f0f\u662f\u4e00\u4e2a\u5b57\u7b26\u4e00\u4e2a\u5b57\u7b26\u8fdb\u884c\u7684\uff0c\u6bd4\u8f83\u7684\u4f9d\u636e\u662f\u4e24\u4e2a\u5b57\u7b26\u5728\u5b57\u7b26\u96c6\u4e2d\u7684\u5148\u540e\u987a\u5e8f\u3002\u5728\u5927\u591a\u6570\u5b57\u7b26\u96c6\u4e2d\uff0c\u540c\u4e00\u4e2a\u5b57\u6bcd\u7684\u5927\u5c0f\u5199\u5f80\u5f80\u6709\u7740\u76f8\u540c\u7684\u5148\u540e\u987a\u5e8f\uff0c\u6240\u4ee5\u5b83\u4e0d\u533a\u5206\u5927\u5c0f\u5199\u3002 <\/p>\n

\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u4e0e\u5b57\u7b26\u96c6\u65e0\u5173\uff0c\u6240\u4ee5\u65e0\u8bba\u6309\u5b57\u7b26\u8ba1\u7b97\u8fd8\u662f\u6309\u5b57\u8282\u8ba1\u7b97\uff0c\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u7684\u957f\u5ea6\u90fd\u662f\u4e00\u6837\u7684\u3002\u6240\u4ee5VARCHAR(20)\u5e76\u4e0d\u8868\u793a\u5b83\u6700\u591a\u80fd\u5bb9\u7eb320\u4e2a\u5b57\u7b26\uff0c\u800c\u662f\u8868\u793a\u5b83\u6700\u591a\u53ea\u80fd\u5bb9\u7eb3\u53ef\u4ee5\u752820\u4e2a\u5b57\u8282\u8868\u793a\u51fa\u6765\u7684\u5b57\u7b26\u3002\u5bf9\u4e8e\u5355\u5b57\u8282\u5b57\u7b26\u96c6\uff0c\u6bcf\u4e2a\u5b57\u7b26\u53ea\u5360\u7528\u4e00\u4e2a\u5b57\u8282\uff0c\u6240\u4ee5\u8fd9\u4e24\u8005\u7684\u957f\u5ea6\u662f\u4e00\u6837\u7684\uff0c\u4f46\u5bf9\u4e8e\u591a\u5b57\u8282\u5b57\u7b26\u96c6\uff0c\u5b83\u80fd\u5bb9\u7eb3\u7684\u5b57\u7b26\u4e2a\u6570\u80af\u5b9a\u5c11\u4e8e20\u4e2a\u3002 <\/p>\n

CHAR\u548cVARCHAR <\/p>\n

CHAR\u548cVARCHAR\u662f\u6700\u5e38\u7528\u7684\u4e24\u79cd\u5b57\u7b26\u4e32\u7c7b\u578b\uff0c\u5b83\u4eec\u4e4b\u95f4\u7684\u533a\u522b\u662f\uff1a <\/p>\n

CHAR\u662f\u56fa\u5b9a\u957f\u5ea6\u7684\uff0c\u6bcf\u4e2a\u503c\u5360\u7528\u76f8\u540c\u7684\u5b57\u8282\uff0c\u4e0d\u591f\u7684\u4f4d\u6570MySQL\u4f1a\u5728\u5b83\u7684\u53f3\u8fb9\u7528\u7a7a\u683c\u5b57\u7b26\u8865\u8db3\u3002 <\/p>\n

VARCHAR\u662f\u4e00\u79cd\u53ef\u53d8\u957f\u5ea6\u7684\u7c7b\u578b\uff0c\u6bcf\u4e2a\u503c\u5360\u7528\u5176\u521a\u597d\u7684\u5b57\u8282\u6570\u518d\u52a0\u4e0a\u4e00\u4e2a\u7528\u6765\u8bb0\u5f55\u5176\u957f\u5ea6\u7684\u5b57\u8282\u5373L+1\u5b57\u8282\u3002 <\/p>\n

CHAR(0)\u548cVARCHAR(0)\u90fd\u662f\u5408\u6cd5\u7684\u3002VARCHAR(0)\u662f\u4eceMySQL4.0.2\u7248\u5f00\u59cb\u7684\u3002\u5b83\u4eec\u7684\u4f5c\u7528\u662f\u4f5c\u4e3a\u5360\u4f4d\u7b26\u6216\u7528\u6765\u8868\u793a\u5404\u79cdon\/off\u5f00\u5173\u503c\u3002 <\/p>\n

\u5982\u4f55\u9009\u62e9CHAR\u548cVARCHAR\uff0c\u8fd9\u91cc\u7ed9\u51fa\u4e24\u4e2a\u539f\u5219\uff1a <\/p>\n

\u5982\u679c\u6570\u636e\u90fd\u6709\u76f8\u540c\u7684\u957f\u5ea6\uff0c\u9009\u7528VARCHAR\u4f1a\u591a\u5360\u7528\u7a7a\u95f4\uff0c\u56e0\u4e3a\u6709\u4e00\u4f4d\u7528\u6765\u5b58\u50a8\u5176\u957f\u5ea6\u3002\u5982\u679c\u6570\u636e\u957f\u77ed\u4e0d\u4e00\uff0c\u9009\u7528VARCHAR\u80fd\u8282\u7701\u5b58\u50a8\u7a7a\u95f4\u3002\u800cCHAR\u4e0d\u8bba\u5b57\u7b26\u957f\u77ed\u90fd\u9700\u5360\u7528\u76f8\u540c\u7684\u7a7a\u95f4\uff0c\u5373\u4f7f\u662f\u7a7a\u503c\u4e5f\u4e0d\u4f8b\u5916\u3002 <\/p>\n

\u5982\u679c\u957f\u5ea6\u51fa\u5165\u4e0d\u5927\uff0c\u800c\u4e14\u662f\u4f7f\u7528MyISAM\u6216ISAM\u7c7b\u578b\u7684\u8868\uff0c\u5219\u7528CHAR\u4f1a\u6bd4VARCHAR\u597d\uff0c\u56e0\u4e3aMyISAM\u548cISAM\u7c7b\u578b\u7684\u8868\u5bf9\u5904\u7406\u56fa\u5b9a\u957f\u5ea6\u7684\u884c\u7684\u6548\u7387\u9ad8\u3002 <\/p>\n

\u5728\u4e00\u4e2a\u6570\u636e\u8868\u91cc\uff0c\u53ea\u8981\u6709\u4e00\u4e2a\u6570\u636e\u5217\u7684\u957f\u5ea6\u662f\u53ef\u53d8\u7684\uff0c\u5219\u6240\u6709\u6570\u636e\u5217\u7684\u957f\u5ea6\u5c06\u662f\u53ef\u53d8\u7684\u3002MySQL\u4f1a\u8fdb\u884c\u81ea\u52a8\u5730\u8f6c\u6362\u3002\u4e00\u4e2a\u4f8b\u5916\uff0cCHAR\u957f\u5ea6\u5c0f\u4e8e4\u7684\u4e0d\u4f1a\u8fdb\u884c\u81ea\u52a8\u8f6c\u6362\uff0c\u56e0\u4e3aMySQL\u4f1a\u8ba4\u4e3a\u8fd9\u6837\u505a\u6ca1\u5fc5\u8981\uff0c\u8282\u7701\u4e0d\u4e86\u591a\u5c11\u7a7a\u95f4\u3002\u53cd\u800cMySQL\u4f1a\u628a\u5927\u91cf\u957f\u5ea6\u5c0f\u7684VARCHAR\u8f6c\u6362\u6210CHAR\uff0c\u4ee5\u51cf\u5c11\u7a7a\u95f4\u5360\u7528\u91cf\u3002 <\/p>\n

BLOB\u548cTEXT <\/p>\n

BLOB\u662f\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\uff0cTEXT\u662f\u975e\u4e8c\u8fdb\u5236\u5b57\u7b26\u4e32\u3002\u4e24\u8005\u90fd\u53ef\u5b58\u653e\u5927\u5bb9\u91cf\u7684\u4fe1\u606f\u3002 <\/p>\n

\u6709\u5173BLOB\u548cTEXT\u7d22\u5f15\u7684\u5efa\u7acb\uff1a <\/p>\n

BDB\u8868\u7c7b\u578b\u548cMySQL3.23.2\u4ee5\u4e0a\u7248\u672c\u7684MyISAM\u8868\u7c7b\u578b\u5141\u8bb8\u5728BLOB\u548cTEXT\u6570\u636e\u5217\u4e0a\u5efa\u7acb\u7d22\u5f15\u3002 <\/p>\n

ISAM\u3001HEAP\u548cInnoDB\u8868\u4e0d\u652f\u6301\u5927\u5bf9\u8c61\u5217\u7684\u7d22\u5f15\u3002 <\/p>\n

\u4f7f\u7528BLOB\u548cTEXT\u5e94\u6ce8\u610f\u7684\u95ee\u9898\uff1a <\/p>\n

\u7531\u4e8e\u8fd9\u4e24\u4e2a\u5217\u7c7b\u578b\u6240\u5b58\u50a8\u7684\u6570\u636e\u91cf\u5927\uff0c\u6240\u4ee5\u5220\u9664\u548c\u4fee\u6539\u64cd\u4f5c\u5bb9\u6613\u5728\u6570\u636e\u8868\u91cc\u4ea7\u751f\u5927\u91cf\u7684\u788e\u7247\uff0c\u9700\u5b9a\u671f\u8fd0\u884cOPTIMIZE TABLE\u4ee5\u51cf\u5c11\u788e\u7247\u548c\u63d0\u9ad8\u6027\u80fd\u3002 <\/p>\n

\u5982\u679c\u4f7f\u7528\u7684\u503c\u975e\u5e38\u5de8\u5927\uff0c\u5c31\u9700\u5bf9\u670d\u52a1\u5668\u8fdb\u884c\u76f8\u5e94\u7684\u4f18\u5316\u8c03\u6574\uff0c\u589e\u52a0max_allowed_packet\u53c2\u6570\u7684\u503c\u3002\u5bf9\u90a3\u4e9b\u53ef\u4f1a\u7528\u5230\u53d8\u4e9b\u5de8\u5927\u6570\u636e\u7684\u5ba2\u6237\u7a0b\u5e8f\uff0c\u4e5f\u9700\u52a0\u5927\u5b83\u4eec\u7684\u6570\u636e\u5305\u5927\u5c0f\u3002 <\/p>\n

ENUM\u548cSET <\/p>\n

ENUM\u548cSET\u90fd\u662f\u6bd4\u8f83\u7279\u6b8a\u7684\u5b57\u7b26\u4e32\u6570\u636e\u5217\u7c7b\u578b\uff0c\u5b83\u4eec\u7684\u53d6\u503c\u8303\u56f4\u662f\u4e00\u4e2a\u9884\u5148\u5b9a\u4e49\u597d\u7684\u5217\u8868\u3002ENUM\u6216SET\u6570\u636e\u5217\u7684\u53d6\u503c\u53ea\u80fd\u4ece\u8fd9\u4e2a\u5217\u8868\u4e2d\u8fdb\u884c\u9009\u62e9\u3002ENUM\u548cSET\u7684\u4e3b\u8981\u533a\u522b\u662f\uff1a <\/p>\n

ENUM\u53ea\u80fd\u53d6\u5355\u503c\uff0c\u5b83\u7684\u6570\u636e\u5217\u8868\u662f\u4e00\u4e2a\u679a\u4e3e\u96c6\u5408\u3002\u5b83\u7684\u5408\u6cd5\u53d6\u503c\u5217\u8868\u6700\u591a\u5141\u8bb8\u670965535\u4e2a\u6210\u5458\u3002\u4f8b\u5982\uff1aENUM(“N”,”Y”)\u8868\u793a\uff0c\u8be5\u6570\u636e\u5217\u7684\u53d6\u503c\u8981\u4e48\u662f”Y”\uff0c\u8981\u4e48\u5c31\u662f”N”\u3002 <\/p>\n

SET\u53ef\u53d6\u591a\u503c\u3002\u5b83\u7684\u5408\u6cd5\u53d6\u503c\u5217\u8868\u6700\u591a\u5141\u8bb8\u670964\u4e2a\u6210\u5458\u3002\u7a7a\u5b57\u7b26\u4e32\u4e5f\u662f\u4e00\u4e2a\u5408\u6cd5\u7684SET\u503c\u3002 <\/p>\n

ENUM\u548cSET\u7684\u503c\u662f\u4ee5\u5b57\u7b26\u4e32\u5f62\u5f0f\u51fa\u73b0\u7684\uff0c\u4f46\u5728\u5185\u90e8\uff0cMySQL\u4ee5\u6570\u503c\u7684\u5f62\u5f0f\u5b58\u50a8\u5b83\u4eec\u3002 <\/p>\n

ENUM\u7684\u5408\u6cd5\u53d6\u503c\u5217\u8868\u4e2d\u7684\u5b57\u7b26\u4e32\u88ab\u6309\u58f0\u660e\u5b9a\u4e49\u7684\u987a\u5e8f\u88ab\u7f16\u53f7\uff0c\u4ece1\u5f00\u59cb\u3002 <\/p>\n

SET\u7684\u7f16\u53f7\u4e0d\u662f\u6309\u987a\u5e8f\u8fdb\u884c\u7f16\u53f7\u7684\uff0cSET\u4e2d\u6bcf\u4e00\u4e2a\u5408\u6cd5\u53d6\u503c\u90fd\u5bf9\u5e94\u7740SET\u503c\u91cc\u7684\u4e00\u4e2a\u4f4d\u3002\u7b2c\u4e00\u4e2a\u5408\u6cd5\u53d6\u503c\u5bf9\u5e940\u4f4d\uff0c\u7b2c\u4e8c\u4e2a\u5408\u6cd5\u53d6\u503c\u5bf9\u5e941\u4f4d\uff0c\u4ee5\u6b64\u7c7b\u63a8\uff0c\u5982\u679c\u6570\u503c\u5f62\u5f0f\u7684SET\u503c\u7b49\u4e8e0,\u5219\u8bf4\u660e\u5b83\u662f\u4e00\u4e2a\u7a7a\u5b57\u7b26\u4e32\uff0c\u5982\u679c\u67d0\u4e2a\u5408\u6cd5\u7684\u53d6\u503c\u51fa\u73b0\u5728SET\u6570\u636e\u5217\u91cc\uff0c\u4e0e\u4e4b\u5bf9\u5e94\u7684\u4f4d\u5c31\u4f1a\u88ab\u7f6e\u4f4d\uff1b\u5982\u679c\u67d0\u4e2a\u5408\u6cd5\u7684\u53d6\u503c\u6ca1\u6709\u51fa\u73b0\u5728 SET\u6570\u636e\u5217\u91cc\uff0c\u4e0e\u4e4b\u5bf9\u5e94\u7684\u4f4d\u5c31\u4f1a\u88ab\u6e05\u96f6\u3002\u6b63\u56e0\u4e3aSET\u503c\u4e0e\u4f4d\u6709\u8fd9\u6837\u7684\u5bf9\u5e94\u5173\u7cfb\uff0c\u6240\u4ee5SET\u6570\u636e\u5217\u7684\u591a\u4e2a\u5408\u6cd5\u53d6\u503c\u624d\u80fd\u540c\u65f6\u51fa\u73b0\u5e76\u6784\u6210SET\u503c\u3002 <\/p>\n

\u5b57\u7b26\u4e32\u7c7b\u578b\u6570\u636e\u5217\u7684\u5b57\u7b26\u96c6\u5c5e\u6027 <\/p>\n

\u5728MySQL 4.1\u4ee5\u524d\u7684\u7248\u672c\uff0c\u5b57\u7b26\u4e32\u6570\u636e\u5217\u7684\u5b57\u7b26\u96c6\u7531\u670d\u52a1\u5668\u7684\u5b57\u7b26\u51b3\u5b9a\uff0cMySQL 4.1\u7248\u4ee5\u540e\u7684\u7248\u672c\u53ef\u5bf9\u6bcf\u4e2a\u5b57\u7b26\u4e32\u6570\u636e\u5217\u6307\u5b9a\u4e0d\u540c\u7684\u5b57\u7b26\u4e32\u3002\u5982\u679c\u6309\u9ed8\u8ba4\u65b9\u5f0f\u8bbe\u7f6e\uff0c\u53ef\u6309\u6570\u636e\u5217\u3001\u6570\u636e\u8868\u3001\u6570\u636e\u5e93\u3001\u670d\u52a1\u5668\u7684\u987a\u5e8f\u5173\u8054\u5b57\u7b26\u4e32\u7684\u5b57\u7b26\u96c6\uff0c\u76f4\u5230\u627e\u4e00\u4e2a\u660e\u786e\u5b9a\u4e49\u7684\u5b57\u7b26\u96c6\u3002 <\/p>\n

\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/ <\/p>\n

\u65e5\u671f,\u65f6\u95f4\u578b\u6570\u636e\u5217\u7c7b\u578b <\/p>\n

DATE 1000-01-01~9999-12-31 3\u5b57\u8282(MySQL3.23\u7248\u4ee5\u524d\u662f4\u5b57\u8282 ) 0000-00-00
\nTIME -838:59:59~838:59:59 3\u5b57\u8282 00:00:00
\nDATETIME 1000-01-01 00:00:00~9999-12-31 23:59:59 8\u5b57\u8282 0000-00-00 00:00:00
\nTIMESTAMP 19700101000000~2037\u5e74\u7684\u67d0\u4e2a\u65f6\u523b 4\u5b57\u8282 00000000000000
\nYEAR YEAR(4)\uff1a1901~2155 YEAR(2)\uff1a1970~2069 1\u5b57\u8282 0000 <\/p>\n

MySQL\u603b\u662f\u628a\u65e5\u671f\u548c\u65e5\u671f\u91cc\u7684\u5e74\u4efd\u653e\u5728\u6700\u524d\u9762\uff0c\u6309\u5e74\u6708\u65e5\u7684\u987a\u5e8f\u663e\u793a\u3002 <\/p>\n

DATE\u3001TIME\u3001DATATIME\u6570\u636e\u5217\u7c7b\u578b <\/p>\n

DATE\u3001TIME\u548cDATATIME\u7c7b\u578b\u5206\u522b\u5b58\u653e\u65e5\u671f\u503c\u3001\u65f6\u95f4\u503c\u3001\u65e5\u671f\u548c\u65f6\u95f4\u503c\u7684\u7ec4\u5408\u3002\u5b83\u4eec\u7684\u683c\u5f0f\u5206\u522b\u662f\u201cCCYY-MM-DD\u201d\u3001\u201chh:mm:ss\u201d\u3001\u201cCCYY-MM-DD hh:mm:ss\u201d\u3002 <\/p>\n

DATATIME\u91cc\u7684\u65f6\u95f4\u503c\u548cTIME\u503c\u662f\u6709\u533a\u522b\u7684\uff0cDATATIME\u91cc\u7684\u65f6\u95f4\u503c\u4ee3\u8868\u7684\u662f\u51e0\u70b9\u51e0\u5206\uff0cTIME\u503c\u4ee3\u8868\u7684\u662f\u6240\u82b1\u8d39\u7684\u65f6\u95f4\u3002\u5f53\u5411TIME\u6570\u636e\u5217\u63d2\u503c\u65f6\uff0c\u9700\u7528\u65f6\u95f4\u7684\u5b8c\u6574\u5199\u6cd5\uff0c\u598212\u520630\u79d2\u8981\u5199\u6210\u201c00:12:30\u201d\u3002 <\/p>\n

TIMESTAMP\u6570\u636e\u5217\u7c7b\u578b <\/p>\n

TIMESTAMP\u6570\u636e\u5217\u7684\u683c\u5f0f\u662fCCYYMMDDhhmmss\uff0c\u53d6\u503c\u8303\u56f4\u4ece19700101000000\u5f00\u59cb\uff0c\u53731970\u5e741\u67081\u53f7\uff0c\u6700\u5927\u52302037\u5e74\u3002\u5b83\u7684\u7279\u70b9\u662f\u80fd\u628a\u6570\u636e\u884c\u7684\u521b\u5efa\u6216\u4fee\u6539\u65f6\u95f4\u8bb0\u5f55\u4e0b\u6765\uff1a <\/p>\n

\u5982\u679c\u628a\u4e00\u4e2aNULL\u503c\u63d2\u5165TIMESTAMP\u5217\uff0c\u8fd9\u4e2a\u6570\u636e\u5217\u5c31\u5c06\u81ea\u52a8\u53d6\u503c\u4e3a\u5f53\u524d\u7684\u65e5\u671f\u548c\u65f6\u95f4\u3002 <\/p>\n

\u5728\u521b\u5efa\u548c\u4fee\u6539\u6570\u636e\u884c\u65f6\uff0c\u5982\u679c\u6ca1\u6709\u660e\u786e\u5bf9TIMESTAMP\u6570\u636e\u5217\u8fdb\u884c\u8d4b\u503c\uff0c\u5219\u5b83\u5c31\u4f1a\u81ea\u52a8\u53d6\u503c\u4e3a\u5f53\u524d\u7684\u65e5\u671f\u548c\u65f6\u95f4\u3002\u5982\u679c\u884c\u4e2d\u6709\u591a\u4e2aTIMESTAMP\u5217\uff0c\u53ea\u6709\u7b2c\u4e00\u4e2a\u4f1a\u81ea\u52a8\u53d6\u503c\u3002 <\/p>\n

\u5982\u679c\u5bf9TIMESTAMP\u8bbe\u7f6e\u4e00\u4e2a\u786e\u5b9a\u7684\u65e5\u671f\u548c\u65f6\u95f4\u503c\uff0c\u5219\u4f1a\u4f7fTIMESTAMP\u7684\u81ea\u52a8\u53d6\u503c\u529f\u80fd\u5931\u6548\u3002 <\/p>\n

TIMESTAMP\u9ed8\u8ba4\u7684\u5217\u5bbd\u662f14,\u53ef\u6307\u5b9a\u5217\u5bbd\uff0c\u4ee5\u6539\u53d8\u663e\u793a\u6548\u679c\u3002\u4f46\u4e0d\u8bba\u4f60\u6307\u5b9a\u7684\u5217\u5bbd\u5982\u4f55\uff0cMySQL\u90fd\u662f\u4ee54\u5b57\u8282\u6765\u5b58\u50a8TIMESTAMP\u503c\uff0c\u4e5f\u603b\u662f\u4ee514\u4f4d\u7cbe\u5ea6\u6765\u8ba1\u7b97\u3002 <\/p>\n

\u5982\u679c\u9700\u8981\u628a\u521b\u5efa\u65f6\u95f4\u548c\u6700\u8fd1\u4e00\u6b21\u4fee\u6539\u65f6\u95f4\u540c\u65f6\u8bb0\u5f55\u4e0b\u6765\uff0c\u53ef\u4ee5\u7528\u4e24\u4e2a\u65f6\u95f4\u6233\u6765\u8bb0\u5f55\uff0c\u4e00\u4e2a\u8bb0\u5f55\u521b\u5efa\u65f6\u95f4\uff0c\u4e00\u4e2a\u8bb0\u5f55\u4fee\u6539\u65f6\u95f4\u3002\u4e0d\u8fc7\u9700\u8bb0\u4f4f\u4e24\u4ef6\u4e8b\uff0c\u4e00\u662f\u8981\u628a\u8bb0\u5f55\u4fee\u6539\u65f6\u95f4\u7684TIMESTAMP\u6570\u636e\u5217\u653e\u5728\u6700\u524d\u9762\uff0c\u8fd9\u6837\u624d\u4f1a\u81ea\u52a8\u53d6\u503c\uff1b\u4e8c\u662f\u521b\u5efa\u4e00\u6761\u65b0\u8bb0\u5f55\u65f6\uff0c\u8981\u7528now()\u51fd\u6570\u6765\u521d\u59cb\u5316\u521b\u5efa\u65f6\u95f4TIMESTAMP\u6570\u636e\u5217\uff0c\u8fd9\u6837\uff0c\u8be5TIMESTAMP\u6570\u636e\u5217\u5c31\u4e0d\u4f1a\u518d\u53d8\u5316\u3002 <\/p>\n

YEAR <\/p>\n

YEAR\u662f\u4e00\u79cd\u5355\u5b57\u8282\u7684\u6570\u636e\u5217\u7c7b\u578b\uff0cYEAR(4)\u7684\u53d6\u503c\u8303\u56f4\u662f1901~2155,YEAR(2)\u7684\u53d6\u503c\u8303\u56f4\u662f1970~2069,\u4f46\u53ea\u663e\u793a\u6700\u540e\u4e24\u4f4d\u6570\u3002MySQL\u80fd\u81ea\u52a8\u628a\u4e24\u4f4d\u6570\u5b57\u5e74\u4efd\u8f6c\u6362\u6210\u56db\u4f4d\u6570\u5b57\u7684\u5e74\u4efd\uff0c\u598297\u548c14\u5206\u88ab\u8f6c\u6362\u62101997\u548c2014\u3002\u8f6c\u6362\u89c4\u5219\u662f\u8fd9\u6837\u7684\uff1a <\/p>\n

\u5e74\u4efd\u503c00~69\u5c06\u88ab\u8f6c\u6362\u62102000~2069\uff1b <\/p>\n

\u5e74\u4efd\u503c70~99\u5c06\u88ab\u8f6c\u6362\u62101970~1999\u3002 <\/p>\n

00\u88ab\u8f6c\u6362\u62100000,\u800c\u4e0d\u662f2000\u3002\u56e0\u4e3a\u6570\u503c00\u4e5f\u5c31\u662f0,\u800c0\u503c\u662fYEAR\u7684\u4e00\u4e2a\u5408\u6cd5\u53d6\u503c<\/p>\n","protected":false},"excerpt":{"rendered":"

MySQL\u6570\u636e\u5e93\u7684\u8868\u662f\u4e00\u4e2a\u4e8c\u7ef4\u8868\uff0c\u7531\u4e00\u4e2a\u6216\u591a\u4e2a\u6570\u636e\u5217\u6784\u6210\u3002 \u6bcf\u4e2a\u6570\u636e\u5217\u90fd\u6709\u5b83\u7684\u7279\u5b9a\u7c7b\u578b\uff0c\u8be5\u7c7b\u578b\u51b3\u5b9a\u4e86MySQL\u5982\u4f55\u770b\u5f85\u8be5\u5217\u6570\u636e\uff0c\u6211\u4eec\u53ef\u4ee5\u628a\u6574\u578b\u6570\u503c\u5b58\u653e\u5230\u5b57\u7b26\u7c7b\u578b\u7684\u5217\u4e2d\uff0cMySQL\u5219\u4f1a\u628a\u5b83\u770b\u6210\u5b57\u7b26\u4e32\u6765\u5904\u7406<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":[],"categories":[1,9],"tags":[23],"_links":{"self":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/184"}],"collection":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/comments?post=184"}],"version-history":[{"count":1,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/184\/revisions"}],"predecessor-version":[{"id":185,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/posts\/184\/revisions\/185"}],"wp:attachment":[{"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/media?parent=184"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/categories?post=184"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/www.youthtribe.com\/wp-json\/wp\/v2\/tags?post=184"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}