{"id":5725,"date":"2024-11-14T11:32:27","date_gmt":"2024-11-14T03:32:27","guid":{"rendered":"https:\/\/fwq.ai\/blog\/5725\/"},"modified":"2024-11-14T11:32:27","modified_gmt":"2024-11-14T03:32:27","slug":"sql%e6%80%8e%e4%b9%88%e5%be%97%e5%88%b0%e5%bd%93%e5%89%8d%e7%9a%84%e6%97%b6%e9%97%b4","status":"publish","type":"post","link":"https:\/\/fwq.ai\/blog\/5725\/","title":{"rendered":"sql\u600e\u4e48\u5f97\u5230\u5f53\u524d\u7684\u65f6\u95f4"},"content":{"rendered":"<blockquote><p>\n  \u5728 sql \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u4ee5\u4e0b\u51fd\u6570\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\uff1a\u4f7f\u7528 current_timestamp\uff0c\u5b83\u5c06\u5728\u6bcf\u6b21\u67e5\u8be2\u65f6\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\u3002\u4f7f\u7528 getdate()\uff08\u4ec5\u9650 microsoft sql server\uff09\uff0c\u5b83\u4f1a\u5728\u67e5\u8be2\u5f00\u59cb\u65f6\u83b7\u53d6\u4e00\u6b21\u65f6\u95f4\uff0c\u7528\u4e8e\u6574\u4e2a\u67e5\u8be2\u3002\n<\/p><\/blockquote>\n<p><img decoding=\"async\" src=\"https:\/\/img.php.cn\/upload\/article\/202405\/30\/2024053021273823014.jpg\" class=\"aligncenter\" title=\"sql\u600e\u4e48\u5f97\u5230\u5f53\u524d\u7684\u65f6\u95f4\u63d2\u56fe\" alt=\"sql\u600e\u4e48\u5f97\u5230\u5f53\u524d\u7684\u65f6\u95f4\u63d2\u56fe\" \/><\/p>\n<p><strong>\u5982\u4f55\u4f7f\u7528 SQL \u83b7\u53d6\u5f53\u524d\u65f6\u95f4<\/strong><\/p>\n<p>\u5728 SQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u73b0\u6210\u7684\u51fd\u6570 CURRENT_TIMESTAMP \u6216 GETDATE() \u6765\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u3002<\/p>\n<p><strong>\u4f7f\u7528 CURRENT_TIMESTAMP<\/strong><\/p>\n<pre>SELECT CURRENT_TIMESTAMP;<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7ed3\u679c\uff1a<\/p>\n<pre>2023-03-08 15:34:12.123456<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u4f7f\u7528 GETDATE() (\u4ec5\u9650 Microsoft SQL Server)<\/strong><\/p>\n<pre>SELECT GETDATE();<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p>\u7ed3\u679c\uff1a<\/p>\n<pre>2023-03-08 15:34:12.123<\/pre>\n<p>  \u767b\u5f55\u540e\u590d\u5236   <\/p>\n<p><strong>\u6ce8\u610f\u4e8b\u9879<\/strong><\/p>\n<ul>\n<li>CURRENT_TIMESTAMP \u5728\u6bcf\u6b21\u67e5\u8be2\u65f6\u90fd\u4f1a\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\uff0c\u800c GETDATE() \u5219\u5728\u67e5\u8be2\u5f00\u59cb\u65f6\u83b7\u53d6\u4e00\u6b21\u65f6\u95f4\u5e76\u5c06\u5176\u7528\u4e8e\u6574\u4e2a\u67e5\u8be2\u3002<\/li>\n<li>CURRENT_TIMESTAMP \u5bf9\u4e8e\u5e76\u884c\u67e5\u8be2\u66f4\u6709\u7528\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u5e76\u884c\u7ebf\u7a0b\u5c06\u83b7\u53d6\u81ea\u5df1\u7684\u5f53\u524d\u65f6\u95f4\uff0c\u800c GETDATE() \u53ef\u80fd\u5bfc\u81f4\u6240\u6709\u7ebf\u7a0b\u4f7f\u7528\u76f8\u540c\u7684\u65f6\u95f4\u3002<\/li>\n<li>CURRENT_TIMESTAMP \u4e5f\u6bd4 GETDATE() \u66f4\u7cbe\u786e\uff08\u901a\u5e38\u5230\u6beb\u79d2\u7ea7\uff09\u3002<\/li>\n<\/ul>\n<p>\u5176\u4ed6\u4fe1\u606f\uff1a<\/p>\n<ul>\n<li>\u5728\u67d0\u4e9b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf (DBMS) \u4e2d\uff0cCURRENT_TIMESTAMP \u53ef\u4ee5\u7528\u522b\u540d NOW()\u3002<\/li>\n<li>\u5bf9\u4e8e\u7279\u5b9a DBMS \u7684\u8bed\u6cd5\uff0c\u8bf7\u53c2\u9605\u5176\u6587\u6863\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0a\u5c31\u662fsql\u600e\u4e48\u5f97\u5230\u5f53\u524d\u7684\u65f6\u95f4\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>\u5728 sql \u4e2d\uff0c\u53ef\u4ee5\u901a\u8fc7\u4f7f\u7528\u4ee5\u4e0b\u51fd\u6570\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\uff1a\u4f7f\u7528 current_timestamp\uff0c\u5b83\u5c06\u5728\u6bcf\u6b21\u67e5\u8be2\u65f6\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\u3002\u4f7f\u7528 getdate()\uff08\u4ec5\u9650 microsoft sql server\uff09\uff0c\u5b83\u4f1a\u5728\u67e5\u8be2\u5f00\u59cb\u65f6\u83b7\u53d6\u4e00\u6b21\u65f6\u95f4\uff0c\u7528\u4e8e\u6574\u4e2a\u67e5\u8be2\u3002 \u5982\u4f55\u4f7f\u7528 SQL \u83b7\u53d6\u5f53\u524d\u65f6\u95f4 \u5728 SQL \u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528\u73b0\u6210\u7684\u51fd\u6570 CURRENT_TIMESTAMP \u6216 GETDATE() \u6765\u83b7\u53d6\u5f53\u524d\u65f6\u95f4\u3002 \u4f7f\u7528 CURRENT_TIMESTAMP SELECT CURRENT_TIMESTAMP; \u767b\u5f55\u540e\u590d\u5236 \u7ed3\u679c\uff1a 2023-03-08 15:34:12.123456 \u767b\u5f55\u540e\u590d\u5236 \u4f7f\u7528 GETDATE() (\u4ec5\u9650 Microsoft SQL Server) SELECT GETDATE(); \u767b\u5f55\u540e\u590d\u5236 \u7ed3\u679c\uff1a 2023-03-08 15:34:12.123 \u767b\u5f55\u540e\u590d\u5236 \u6ce8\u610f\u4e8b\u9879 CURRENT_TIMESTAMP \u5728\u6bcf\u6b21\u67e5\u8be2\u65f6\u90fd\u4f1a\u8fd4\u56de\u5f53\u524d\u65f6\u95f4\uff0c\u800c GETDATE() \u5219\u5728\u67e5\u8be2\u5f00\u59cb\u65f6\u83b7\u53d6\u4e00\u6b21\u65f6\u95f4\u5e76\u5c06\u5176\u7528\u4e8e\u6574\u4e2a\u67e5\u8be2\u3002 CURRENT_TIMESTAMP \u5bf9\u4e8e\u5e76\u884c\u67e5\u8be2\u66f4\u6709\u7528\uff0c\u56e0\u4e3a\u6bcf\u4e2a\u5e76\u884c\u7ebf\u7a0b\u5c06\u83b7\u53d6\u81ea\u5df1\u7684\u5f53\u524d\u65f6\u95f4\uff0c\u800c GETDATE() \u53ef\u80fd\u5bfc\u81f4\u6240\u6709\u7ebf\u7a0b\u4f7f\u7528\u76f8\u540c\u7684\u65f6\u95f4\u3002 CURRENT_TIMESTAMP \u4e5f\u6bd4 GETDATE() \u66f4\u7cbe\u786e\uff08\u901a\u5e38\u5230\u6beb\u79d2\u7ea7\uff09\u3002 \u5176\u4ed6\u4fe1\u606f\uff1a \u5728\u67d0\u4e9b\u6570\u636e\u5e93\u7ba1\u7406\u7cfb\u7edf [&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-5725","post","type-post","status-publish","format-standard","hentry","category-16"],"_links":{"self":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5725","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=5725"}],"version-history":[{"count":0,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/posts\/5725\/revisions"}],"wp:attachment":[{"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/media?parent=5725"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/categories?post=5725"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/fwq.ai\/blog\/wp-json\/wp\/v2\/tags?post=5725"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}