{"id":95764,"date":"2024-10-20T03:48:18","date_gmt":"2024-10-19T19:48:18","guid":{"rendered":"https:\/\/server.hk\/cnblog\/95764\/"},"modified":"2024-10-20T03:48:18","modified_gmt":"2024-10-19T19:48:18","slug":"oracle%e6%95%b8%e6%93%9a%e5%ba%ab%e6%97%a5%e6%9c%9f%e5%87%bd%e6%95%b8%e5%a4%a7%e5%85%a8%ef%bc%8c%e5%bf%85%e5%82%99%e6%8a%80%e8%83%bd%ef%bc%81-oracle%e6%95%b8%e6%93%9a%e5%ba%ab%e4%b8%ad%e7%9a%84","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/95764\/","title":{"rendered":"Oracle\u6578\u64da\u5eab\u65e5\u671f\u51fd\u6578\u5927\u5168\uff0c\u5fc5\u5099\u6280\u80fd\uff01 (oracle\u6578\u64da\u5eab\u4e2d\u7684\u65e5\u671f\u51fd\u6578)"},"content":{"rendered":"<h1 id=\"oracle%e6%95%b8%e6%93%9a%e5%ba%ab%e6%97%a5%e6%9c%9f%e5%87%bd%e6%95%b8%e5%a4%a7%e5%85%a8%ef%bc%8c%e5%bf%85%e5%82%99%e6%8a%80%e8%83%bd%ef%bc%81-IKudQvzjeR\">Oracle\u6578\u64da\u5eab\u65e5\u671f\u51fd\u6578\u5927\u5168\uff0c\u5fc5\u5099\u6280\u80fd\uff01<\/h1>\n<p>\u5728Oracle\u6578\u64da\u5eab\u4e2d\uff0c\u65e5\u671f\u548c\u6642\u9593\u7684\u8655\u7406\u662f\u975e\u5e38\u91cd\u8981\u7684\uff0c\u56e0\u70ba\u8a31\u591a\u61c9\u7528\u7a0b\u5e8f\u90fd\u9700\u8981\u5c0d\u6642\u9593\u9032\u884c\u8a08\u7b97\u548c\u6bd4\u8f03\u3002Oracle\u63d0\u4f9b\u4e86\u4e00\u7cfb\u5217\u5f37\u5927\u7684\u65e5\u671f\u51fd\u6578\uff0c\u5e6b\u52a9\u7528\u6236\u8f15\u9b06\u5730\u9032\u884c\u65e5\u671f\u548c\u6642\u9593\u7684\u64cd\u4f5c\u3002\u672c\u6587\u5c07\u4ecb\u7d39\u4e00\u4e9b\u5e38\u7528\u7684Oracle\u65e5\u671f\u51fd\u6578\uff0c\u4e26\u63d0\u4f9b\u76f8\u61c9\u7684\u793a\u4f8b\uff0c\u5e6b\u52a9\u8b80\u8005\u638c\u63e1\u9019\u4e9b\u5fc5\u5099\u6280\u80fd\u3002<\/p>\n<h2 id=\"1-sysdate-IKudQvzjeR\">1. SYSDATE<\/h2>\n<p>SYSDATE\u51fd\u6578\u8fd4\u56de\u7576\u524d\u7684\u7cfb\u7d71\u65e5\u671f\u548c\u6642\u9593\u3002\u9019\u662f\u6700\u5e38\u7528\u7684\u65e5\u671f\u51fd\u6578\u4e4b\u4e00\u3002<\/p>\n<pre><code>SELECT SYSDATE FROM dual;<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de\u7576\u524d\u7684\u65e5\u671f\u548c\u6642\u9593\u3002<\/p>\n<h2 id=\"2-current_date-IKudQvzjeR\">2. CURRENT_DATE<\/h2>\n<p>CURRENT_DATE\u51fd\u6578\u8fd4\u56de\u7576\u524d\u6703\u8a71\u7684\u65e5\u671f\u548c\u6642\u9593\uff0c\u6839\u64da\u6703\u8a71\u7684\u6642\u5340\u9032\u884c\u8abf\u6574\u3002<\/p>\n<pre><code>SELECT CURRENT_DATE FROM dual;<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de\u7576\u524d\u6703\u8a71\u7684\u65e5\u671f\u548c\u6642\u9593\u3002<\/p>\n<h2 id=\"3-add_months-IKudQvzjeR\">3. ADD_MONTHS<\/h2>\n<p>ADD_MONTHS\u51fd\u6578\u7528\u65bc\u5c07\u6307\u5b9a\u7684\u6708\u4efd\u6578\u6dfb\u52a0\u5230\u7d66\u5b9a\u7684\u65e5\u671f\u4e0a\u3002<\/p>\n<pre><code>SELECT ADD_MONTHS(SYSDATE, 3) FROM dual;<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de\u7576\u524d\u65e5\u671f\u52a0\u4e0a\u4e09\u500b\u6708\u7684\u65e5\u671f\u3002<\/p>\n<h2 id=\"4-months_between-IKudQvzjeR\">4. MONTHS_BETWEEN<\/h2>\n<p>MONTHS_BETWEEN\u51fd\u6578\u8a08\u7b97\u5169\u500b\u65e5\u671f\u4e4b\u9593\u7684\u6708\u4efd\u6578\u3002<\/p>\n<pre><code>SELECT MONTHS_BETWEEN('2023-12-31', '2023-01-01') FROM dual;<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de2023\u5e741\u67081\u65e5\u52302023\u5e7412\u670831\u65e5\u4e4b\u9593\u7684\u6708\u4efd\u6578\u3002<\/p>\n<h2 id=\"5-last_day-IKudQvzjeR\">5. LAST_DAY<\/h2>\n<p>LAST_DAY\u51fd\u6578\u8fd4\u56de\u6307\u5b9a\u65e5\u671f\u6240\u5728\u6708\u4efd\u7684\u6700\u5f8c\u4e00\u5929\u3002<\/p>\n<pre><code>SELECT LAST_DAY(SYSDATE) FROM dual;<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de\u7576\u524d\u6708\u4efd\u7684\u6700\u5f8c\u4e00\u5929\u3002<\/p>\n<h2 id=\"6-trunc-IKudQvzjeR\">6. TRUNC<\/h2>\n<p>TRUNC\u51fd\u6578\u7528\u65bc\u5c07\u65e5\u671f\u622a\u65b7\u5230\u6307\u5b9a\u7684\u7cbe\u5ea6\u3002\u53ef\u4ee5\u7528\u4f86\u53bb\u6389\u6642\u9593\u90e8\u5206\uff0c\u53ea\u4fdd\u7559\u65e5\u671f\u3002<\/p>\n<pre><code>SELECT TRUNC(SYSDATE) FROM dual;<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de\u7576\u524d\u65e5\u671f\uff0c\u6642\u9593\u90e8\u5206\u5c07\u88ab\u622a\u65b7\u3002<\/p>\n<h2 id=\"7-extract-IKudQvzjeR\">7. EXTRACT<\/h2>\n<p>EXTRACT\u51fd\u6578\u7528\u65bc\u5f9e\u65e5\u671f\u4e2d\u63d0\u53d6\u7279\u5b9a\u7684\u90e8\u5206\uff0c\u4f8b\u5982\u5e74\u3001\u6708\u6216\u65e5\u3002<\/p>\n<pre><code>SELECT EXTRACT(YEAR FROM SYSDATE) AS year FROM dual;<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de\u7576\u524d\u5e74\u4efd\u3002<\/p>\n<h2 id=\"8-to_date-IKudQvzjeR\">8. TO_DATE<\/h2>\n<p>TO_DATE\u51fd\u6578\u7528\u65bc\u5c07\u5b57\u7b26\u4e32\u8f49\u63db\u70ba\u65e5\u671f\u683c\u5f0f\u3002<\/p>\n<pre><code>SELECT TO_DATE('2023-10-01', 'YYYY-MM-DD') FROM dual;<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de2023\u5e7410\u67081\u65e5\u7684\u65e5\u671f\u683c\u5f0f\u3002<\/p>\n<h2 id=\"9-to_char-IKudQvzjeR\">9. TO_CHAR<\/h2>\n<p>TO_CHAR\u51fd\u6578\u7528\u65bc\u5c07\u65e5\u671f\u8f49\u63db\u70ba\u5b57\u7b26\u4e32\u683c\u5f0f\uff0c\u65b9\u4fbf\u986f\u793a\u6216\u8f38\u51fa\u3002<\/p>\n<pre><code>SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD HH24:MI:SS') FROM dual;<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de\u7576\u524d\u65e5\u671f\u548c\u6642\u9593\u7684\u5b57\u7b26\u4e32\u683c\u5f0f\u3002<\/p>\n<h2 id=\"10-systimestamp-IKudQvzjeR\">10. SYSTIMESTAMP<\/h2>\n<p>SYSTIMESTAMP\u51fd\u6578\u8fd4\u56de\u7576\u524d\u7684\u7cfb\u7d71\u6642\u9593\u6233\uff0c\u5305\u62ec\u65e5\u671f\u3001\u6642\u9593\u548c\u6642\u5340\u4fe1\u606f\u3002<\/p>\n<pre><code>SELECT SYSTIMESTAMP FROM dual;<\/code><\/pre>\n<p>\u9019\u689d\u67e5\u8a62\u5c07\u8fd4\u56de\u7576\u524d\u7684\u7cfb\u7d71\u6642\u9593\u6233\u3002<\/p>\n<h2 id=\"%e7%b8%bd%e7%b5%90-IKudQvzjeR\">\u7e3d\u7d50<\/h2>\n<p>\u638c\u63e1Oracle\u6578\u64da\u5eab\u4e2d\u7684\u65e5\u671f\u51fd\u6578\u5c0d\u65bc\u6578\u64da\u7ba1\u7406\u548c\u5206\u6790\u81f3\u95dc\u91cd\u8981\u3002\u9019\u4e9b\u51fd\u6578\u4e0d\u50c5\u80fd\u5920\u5e6b\u52a9\u7528\u6236\u9032\u884c\u65e5\u671f\u8a08\u7b97\uff0c\u9084\u80fd\u63d0\u9ad8\u6578\u64da\u67e5\u8a62\u7684\u6548\u7387\u3002\u7121\u8ad6\u662f\u5728\u958b\u767c\u61c9\u7528\u7a0b\u5e8f\u9084\u662f\u9032\u884c\u6578\u64da\u5206\u6790\u6642\uff0c\u719f\u6089\u9019\u4e9b\u65e5\u671f\u51fd\u6578\u90fd\u662f\u4e00\u9805\u5fc5\u5099\u6280\u80fd\u3002<\/p>\n<p>\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002\u7121\u8ad6\u662f <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u9084\u662f\u5176\u4ed6\u670d\u52d9\uff0c\u6211\u5011\u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22Oracle\u6578\u64da\u5eab\u4e2d\u7684\u65e5\u671f\u51fd\u6578\u5927\u5168\uff0c\u638c\u63e1\u5fc5\u5099\u6280\u80fd\uff0c\u63d0\u5347\u6578\u64da\u8655\u7406\u6548\u7387\uff0c\u8f15\u9b06\u7ba1\u7406\u6642\u9593\u548c\u65e5\u671f\u8cc7\u8a0a\uff01<\/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-95764","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/95764","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=95764"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/95764\/revisions"}],"predecessor-version":[{"id":95765,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/95764\/revisions\/95765"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=95764"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=95764"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=95764"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}