{"id":5691,"date":"2024-11-14T08:18:19","date_gmt":"2024-11-14T00:18:19","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5691\/"},"modified":"2024-11-14T08:18:19","modified_gmt":"2024-11-14T00:18:19","slug":"sql%e6%97%b6%e9%97%b4%e6%88%b3%e6%80%8e%e4%b9%88%e5%86%99","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5691\/","title":{"rendered":"sql\u65f6\u95f4\u6233\u600e\u4e48\u5199"},"content":{"rendered":"<blockquote><p>\n  sql \u65f6\u95f4\u6233\u662f\u4e00\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u7528\u4e8e\u5b58\u50a8\u65e5\u671f\u548c\u65f6\u95f4\u4fe1\u606f\uff0c\u6709\u4ee5\u4e0b\u5e38\u89c1\u573a\u666f\uff1a\u8ddf\u8e2a\u8bb0\u5f55\u521b\u5efa\u6216\u4fee\u6539\u7684\u65f6\u95f4\uff1b\u8bb0\u5f55\u4e8b\u4ef6\u53d1\u751f\u7684\u65f6\u95f4\uff1b\u6bd4\u8f83\u65f6\u95f4\u6233\u4ee5\u786e\u5b9a\u65f6\u95f4\u5dee\uff1b\u6839\u636e\u65f6\u95f4\u8303\u56f4\u8fc7\u6ee4\u6570\u636e\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/30\/2024053020460547630.jpg\" class=\"aligncenter\" title=\"sql\u65f6\u95f4\u6233\u600e\u4e48\u5199\u63d2\u56fe\" alt=\"sql\u65f6\u95f4\u6233\u600e\u4e48\u5199\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u7f16\u5199 SQL \u65f6\u95f4\u6233<\/strong><\/p>\n<p><strong>\u5165\u95e8<\/strong><br \/>SQL \u65f6\u95f4\u6233\u662f\u4e00\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u7528\u4e8e\u5b58\u50a8\u65e5\u671f\u548c\u65f6\u95f4\u4fe1\u606f\u3002\u5b83\u901a\u5e38\u7528\u4e8e\u8bb0\u5f55\u4e8b\u4ef6\u53d1\u751f\u6216\u8bb0\u5f55\u521b\u5efa\u7684\u65f6\u95f4\u3002<\/p>\n<p><strong>\u8bed\u6cd5<\/strong><br \/>\u5728 SQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\u521b\u5efa\u4e00\u4e2a\u65f6\u95f4\u6233\u5217\uff1a<\/p>\n<pre>CREATE TABLE table_name (\n  timestamp_column TIMESTAMP NOT NULL\n);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>table_name \u662f\u8868\u7684\u540d\u79f0\u3002<\/li>\n<li>timestamp_column \u662f\u65f6\u95f4\u6233\u5217\u7684\u540d\u79f0\u3002<\/li>\n<li>NOT NULL \u8868\u793a\u8be5\u5217\u4e0d\u80fd\u5b58\u50a8 NULL \u503c\u3002<\/li>\n<\/ul>\n<p><strong>\u63d2\u5165\u65f6\u95f4\u6233<\/strong><br \/>\u8981\u63d2\u5165\u65f6\u95f4\u6233\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a<\/p>\n<pre>INSERT INTO table_name (timestamp_column) VALUES (CURRENT_TIMESTAMP);<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>CURRENT_TIMESTAMP \u662f\u4e00\u4e2a\u7279\u6b8a\u503c\uff0c\u5b83\u4ee3\u8868\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u3002<\/li>\n<\/ul>\n<p><strong>\u683c\u5f0f<\/strong><br \/>\u65f6\u95f4\u6233\u503c\u901a\u5e38\u4f7f\u7528\u4ee5\u4e0b\u683c\u5f0f\u5b58\u50a8\uff1a<\/p>\n<pre>YYYY-MM-DD HH:MM:SS.ffffff<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u5176\u4e2d\uff1a<\/p>\n<ul>\n<li>YYYY \u662f\u5e74\u4efd\u3002<\/li>\n<li>MM \u662f\u6708\u4efd\u3002<\/li>\n<li>DD \u662f\u65e5\u671f\u3002<\/li>\n<li>HH \u662f\u5c0f\u65f6\u3002<\/li>\n<li>MM \u662f\u5206\u949f\u3002<\/li>\n<li>SS \u662f\u79d2\u3002<\/li>\n<li>ffffff \u662f\u5fae\u79d2\u3002<\/li>\n<\/ul>\n<p><strong>\u4f7f\u7528\u573a\u666f<\/strong><br \/>\u65f6\u95f4\u6233\u5728 SQL \u4e2d\u6709\u8bb8\u591a\u7528\u9014\uff0c\u5305\u62ec\uff1a<\/p>\n<ul>\n<li>\u8ddf\u8e2a\u8bb0\u5f55\u521b\u5efa\u6216\u4fee\u6539\u7684\u65f6\u95f4\u3002<\/li>\n<li>\u8bb0\u5f55\u4e8b\u4ef6\u53d1\u751f\u7684\u65f6\u95f4\u3002<\/li>\n<li>\u6bd4\u8f83\u4e24\u4e2a\u65f6\u95f4\u6233\u4ee5\u786e\u5b9a\u65f6\u95f4\u5dee\u3002<\/li>\n<li>\u6839\u636e\u65f6\u95f4\u8303\u56f4\u8fc7\u6ee4\u6570\u636e\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u65f6\u95f4\u6233\u600e\u4e48\u5199\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>sql \u65f6\u95f4\u6233\u662f\u4e00\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u7528\u4e8e\u5b58\u50a8\u65e5\u671f\u548c\u65f6\u95f4\u4fe1\u606f\uff0c\u6709\u4ee5\u4e0b\u5e38\u89c1\u573a\u666f\uff1a\u8ddf\u8e2a\u8bb0\u5f55\u521b\u5efa\u6216\u4fee\u6539\u7684\u65f6\u95f4\uff1b\u8bb0\u5f55\u4e8b\u4ef6\u53d1\u751f\u7684\u65f6\u95f4\uff1b\u6bd4\u8f83\u65f6\u95f4\u6233\u4ee5\u786e\u5b9a\u65f6\u95f4\u5dee\uff1b\u6839\u636e\u65f6\u95f4\u8303\u56f4\u8fc7\u6ee4\u6570\u636e\u3002 \u5982\u4f55\u7f16\u5199 SQL \u65f6\u95f4\u6233 \u5165\u95e8SQL \u65f6\u95f4\u6233\u662f\u4e00\u79cd\u6570\u636e\u7c7b\u578b\uff0c\u7528\u4e8e\u5b58\u50a8\u65e5\u671f\u548c\u65f6\u95f4\u4fe1\u606f\u3002\u5b83\u901a\u5e38\u7528\u4e8e\u8bb0\u5f55\u4e8b\u4ef6\u53d1\u751f\u6216\u8bb0\u5f55\u521b\u5efa\u7684\u65f6\u95f4\u3002 \u8bed\u6cd5\u5728 SQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\u521b\u5efa\u4e00\u4e2a\u65f6\u95f4\u6233\u5217\uff1a CREATE TABLE table_name ( timestamp_column TIMESTAMP NOT NULL ); \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a table_name \u662f\u8868\u7684\u540d\u79f0\u3002 timestamp_column \u662f\u65f6\u95f4\u6233\u5217\u7684\u540d\u79f0\u3002 NOT NULL \u8868\u793a\u8be5\u5217\u4e0d\u80fd\u5b58\u50a8 NULL \u503c\u3002 \u63d2\u5165\u65f6\u95f4\u6233\u8981\u63d2\u5165\u65f6\u95f4\u6233\u503c\uff0c\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u8bed\u6cd5\uff1a INSERT INTO table_name (timestamp_column) VALUES (CURRENT_TIMESTAMP); \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a CURRENT_TIMESTAMP \u662f\u4e00\u4e2a\u7279\u6b8a\u503c\uff0c\u5b83\u4ee3\u8868\u5f53\u524d\u65e5\u671f\u548c\u65f6\u95f4\u3002 \u683c\u5f0f\u65f6\u95f4\u6233\u503c\u901a\u5e38\u4f7f\u7528\u4ee5\u4e0b\u683c\u5f0f\u5b58\u50a8\uff1a YYYY-MM-DD HH:MM:SS.ffffff \u767b\u5f55\u540e\u590d\u5236 \u5176\u4e2d\uff1a YYYY \u662f\u5e74\u4efd\u3002 MM \u662f\u6708\u4efd\u3002 DD \u662f\u65e5\u671f\u3002 HH \u662f\u5c0f\u65f6\u3002 MM [&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-5691","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5691","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=5691"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5691\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5691"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5691"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5691"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}