{"id":5494,"date":"2024-11-14T09:40:45","date_gmt":"2024-11-14T01:40:45","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5494\/"},"modified":"2024-11-14T09:40:45","modified_gmt":"2024-11-14T01:40:45","slug":"mysql%e6%88%96%e8%80%85%e6%80%8e%e4%b9%88%e8%a1%a8%e7%a4%ba","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5494\/","title":{"rendered":"mysql\u6216\u8005\u600e\u4e48\u8868\u793a"},"content":{"rendered":"<blockquote><p>\n  mysql \u4e2d\u8868\u793a\u65e5\u671f\u548c\u65f6\u95f4\u7684\u7c7b\u578b\u4e3b\u8981\u6709 date \u548c datetime\uff0c\u5206\u522b\u5b58\u50a8\u65e5\u671f\u548c\u65e5\u671f\u65f6\u95f4\u3002\u5176\u4ed6\u76f8\u5173\u6570\u636e\u7c7b\u578b\u5305\u62ec\u81ea\u52a8\u66f4\u65b0\u7684\u65f6\u95f4\u6233 timestamp\uff0c\u4ec5\u5b58\u50a8\u65f6\u95f4\u90e8\u5206\u7684 time\u3002\u9009\u62e9\u5408\u9002\u7684\u7c7b\u578b\u53d6\u51b3\u4e8e\u5e94\u7528\u7a0b\u5e8f\u5bf9\u65e5\u671f\u548c\u65f6\u95f4\u4fe1\u606f\u7684\u5177\u4f53\u8981\u6c42\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/29\/2024052904302459029.jpg\" class=\"aligncenter\" title=\"mysql\u6216\u8005\u600e\u4e48\u8868\u793a\u63d2\u56fe\" alt=\"mysql\u6216\u8005\u600e\u4e48\u8868\u793a\u63d2\u56fe\" \/><\/p>\n<p><strong>MySQL \u4e2d\u8868\u793a\u65e5\u671f\u548c\u65f6\u95f4\u7684\u7c7b\u578b<\/strong><\/p>\n<p>\u5728 MySQL \u6570\u636e\u5e93\u4e2d\uff0c\u4e3b\u8981\u6709\u4e24\u79cd\u6570\u636e\u7c7b\u578b\u7528\u4e8e\u8868\u793a\u65e5\u671f\u548c\u65f6\u95f4\uff1a<strong>DATE<\/strong> \u548c <strong>DATETIME<\/strong>\u3002<\/p>\n<p><strong>DATE\uff1a<\/strong><\/p>\n<ul>\n<li>\u5b58\u50a8\u4ec5\u5305\u542b\u65e5\u671f\u90e8\u5206\uff0c\u4f8b\u5982\uff1a2023-03-16<\/li>\n<li>\u503c\u7684\u8303\u56f4\u662f 1000-01-01 \u5230 9999-12-31<\/li>\n<\/ul>\n<p><strong>DATETIME\uff1a<\/strong><\/p>\n<ul>\n<li>\u540c\u65f6\u5b58\u50a8\u65e5\u671f\u548c\u65f6\u95f4\u90e8\u5206\uff0c\u4f8b\u5982\uff1a2023-03-16 15:40:05<\/li>\n<li>\u503c\u7684\u8303\u56f4\u662f 1000-01-01 00:00:00 \u5230 9999-12-31 23:59:59<\/li>\n<\/ul>\n<p><strong>\u5176\u4ed6\u76f8\u5173\u6570\u636e\u7c7b\u578b\uff1a<\/strong><\/p>\n<p><strong>TIMESTAMP\uff1a<\/strong><\/p>\n<ul>\n<li>\n<p>\u4e0e DATETIME \u7c7b\u4f3c\uff0c\u4f46\u6709\u51e0\u4e2a\u5173\u952e\u533a\u522b\uff1a<\/p>\n<ul>\n<li>\u5177\u6709\u81ea\u52a8\u66f4\u65b0\u7684\u65f6\u95f4\u6233\u529f\u80fd<\/li>\n<li>\u5b58\u50a8\u7684\u65f6\u95f4\u8303\u56f4\u66f4\u7a84\uff08\u4ece 1970-01-01 00:00:00 \u5230 2038-01-19 03:14:07 UTC\uff09<\/li>\n<\/ul>\n<\/li>\n<\/ul>\n<p><strong>TIME\uff1a<\/strong><\/p>\n<ul>\n<li>\u4ec5\u5b58\u50a8\u65f6\u95f4\u90e8\u5206\uff0c\u4f8b\u5982\uff1a15:40:05<\/li>\n<li>\u503c\u7684\u8303\u56f4\u662f -838:59:59 \u5230 838:59:59<\/li>\n<\/ul>\n<p><strong>\u9009\u62e9\u5408\u9002\u7684\u7c7b\u578b\uff1a<\/strong><\/p>\n<p>\u9009\u62e9\u54ea\u79cd\u6570\u636e\u7c7b\u578b\u53d6\u51b3\u4e8e\u5e94\u7528\u7a0b\u5e8f\u5bf9\u65e5\u671f\u548c\u65f6\u95f4\u4fe1\u606f\u7684\u5177\u4f53\u8981\u6c42\u3002<\/p>\n<ul>\n<li>\u5982\u679c\u53ea\u9700\u8981\u5b58\u50a8\u65e5\u671f\uff0c<strong>DATE<\/strong> \u662f\u6700\u4f73\u9009\u62e9\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u540c\u65f6\u5b58\u50a8\u65e5\u671f\u548c\u65f6\u95f4\uff0c<strong>DATETIME<\/strong> \u662f\u66f4\u597d\u7684\u9009\u62e9\u3002<\/li>\n<li>\u5982\u679c\u9700\u8981\u81ea\u52a8\u66f4\u65b0\u7684\u65f6\u95f4\u6233\uff0c<strong>TIMESTAMP<\/strong> \u662f\u7406\u60f3\u7684\u9009\u62e9\u3002<\/li>\n<li>\u5982\u679c\u4ec5\u9700\u8981\u5b58\u50a8\u65f6\u95f4\u90e8\u5206\uff0c<strong>TIME<\/strong> \u662f\u5408\u9002\u7684\u7c7b\u578b\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662f\u6216\u8005\u600e\u4e48\u8868\u793a\u7684\u8be6\u7ec6\u5185\u5bb9\uff0c\u66f4\u591a\u8bf7\u5173\u6ce8\u7c73\u4e91\u7f51\u5176\u5b83\u76f8\u5173\u6587\u7ae0\uff01<\/p>\n","protected":false},"excerpt":{"rendered":"<p>mysql \u4e2d\u8868\u793a\u65e5\u671f\u548c\u65f6\u95f4\u7684\u7c7b\u578b\u4e3b\u8981\u6709 date \u548c datetime\uff0c\u5206\u522b\u5b58\u50a8\u65e5\u671f\u548c\u65e5\u671f\u65f6\u95f4\u3002\u5176\u4ed6\u76f8\u5173\u6570\u636e\u7c7b\u578b\u5305\u62ec\u81ea\u52a8\u66f4\u65b0\u7684\u65f6\u95f4\u6233 timestamp\uff0c\u4ec5\u5b58\u50a8\u65f6\u95f4\u90e8\u5206\u7684 time\u3002\u9009\u62e9\u5408\u9002\u7684\u7c7b\u578b\u53d6\u51b3\u4e8e\u5e94\u7528\u7a0b\u5e8f\u5bf9\u65e5\u671f\u548c\u65f6\u95f4\u4fe1\u606f\u7684\u5177\u4f53\u8981\u6c42\u3002 MySQL \u4e2d\u8868\u793a\u65e5\u671f\u548c\u65f6\u95f4\u7684\u7c7b\u578b \u5728 MySQL \u6570\u636e\u5e93\u4e2d\uff0c\u4e3b\u8981\u6709\u4e24\u79cd\u6570\u636e\u7c7b\u578b\u7528\u4e8e\u8868\u793a\u65e5\u671f\u548c\u65f6\u95f4\uff1aDATE \u548c DATETIME\u3002 DATE\uff1a \u5b58\u50a8\u4ec5\u5305\u542b\u65e5\u671f\u90e8\u5206\uff0c\u4f8b\u5982\uff1a2023-03-16 \u503c\u7684\u8303\u56f4\u662f 1000-01-01 \u5230 9999-12-31 DATETIME\uff1a \u540c\u65f6\u5b58\u50a8\u65e5\u671f\u548c\u65f6\u95f4\u90e8\u5206\uff0c\u4f8b\u5982\uff1a2023-03-16 15:40:05 \u503c\u7684\u8303\u56f4\u662f 1000-01-01 00:00:00 \u5230 9999-12-31 23:59:59 \u5176\u4ed6\u76f8\u5173\u6570\u636e\u7c7b\u578b\uff1a TIMESTAMP\uff1a \u4e0e DATETIME \u7c7b\u4f3c\uff0c\u4f46\u6709\u51e0\u4e2a\u5173\u952e\u533a\u522b\uff1a \u5177\u6709\u81ea\u52a8\u66f4\u65b0\u7684\u65f6\u95f4\u6233\u529f\u80fd \u5b58\u50a8\u7684\u65f6\u95f4\u8303\u56f4\u66f4\u7a84\uff08\u4ece 1970-01-01 00:00:00 \u5230 2038-01-19 03:14:07 UTC\uff09 TIME\uff1a \u4ec5\u5b58\u50a8\u65f6\u95f4\u90e8\u5206\uff0c\u4f8b\u5982\uff1a15:40:05 \u503c\u7684\u8303\u56f4\u662f -838:59:59 \u5230 838:59:59 \u9009\u62e9\u5408\u9002\u7684\u7c7b\u578b\uff1a \u9009\u62e9\u54ea\u79cd\u6570\u636e\u7c7b\u578b\u53d6\u51b3\u4e8e\u5e94\u7528\u7a0b\u5e8f\u5bf9\u65e5\u671f\u548c\u65f6\u95f4\u4fe1\u606f\u7684\u5177\u4f53\u8981\u6c42\u3002 \u5982\u679c\u53ea\u9700\u8981\u5b58\u50a8\u65e5\u671f\uff0cDATE \u662f\u6700\u4f73\u9009\u62e9\u3002 \u5982\u679c\u9700\u8981\u540c\u65f6\u5b58\u50a8\u65e5\u671f\u548c\u65f6\u95f4\uff0cDATETIME \u662f\u66f4\u597d\u7684\u9009\u62e9\u3002 \u5982\u679c\u9700\u8981\u81ea\u52a8\u66f4\u65b0\u7684\u65f6\u95f4\u6233\uff0cTIMESTAMP [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[16],"tags":[],"class_list":["post-5494","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5494","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/comments?post=5494"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5494\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5494"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5494"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5494"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}