{"id":153739,"date":"2024-11-02T09:57:18","date_gmt":"2024-11-02T01:57:18","guid":{"rendered":"https:\/\/server.hk\/cnblog\/153739\/"},"modified":"2024-11-02T09:57:19","modified_gmt":"2024-11-02T01:57:19","slug":"%e5%b8%b6%e6%82%a8%e4%ba%86%e8%a7%a3oracle%e6%95%b8%e6%93%9a%e8%bd%89%e6%8f%9b%e5%87%bd%e6%95%b8","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/153739\/","title":{"rendered":"\u5e36\u60a8\u4e86\u89e3Oracle\u6578\u64da\u8f49\u63db\u51fd\u6578"},"content":{"rendered":"<h1 id=\"%e5%b8%b6%e6%82%a8%e4%ba%86%e8%a7%a3oracle%e6%95%b8%e6%93%9a%e8%bd%89%e6%8f%9b%e5%87%bd%e6%95%b8-etNRfQonpj\">\u5e36\u60a8\u4e86\u89e3Oracle\u6578\u64da\u8f49\u63db\u51fd\u6578<\/h1>\n<p>\u5728\u6578\u64da\u5eab\u7ba1\u7406\u4e2d\uff0c\u6578\u64da\u8f49\u63db\u662f\u4e00\u500b\u91cd\u8981\u7684\u904e\u7a0b\uff0c\u5c24\u5176\u662f\u5728\u4f7f\u7528Oracle\u6578\u64da\u5eab\u6642\u3002Oracle\u63d0\u4f9b\u4e86\u591a\u7a2e\u6578\u64da\u8f49\u63db\u51fd\u6578\uff0c\u9019\u4e9b\u51fd\u6578\u80fd\u5920\u5e6b\u52a9\u7528\u6236\u5728\u4e0d\u540c\u6578\u64da\u985e\u578b\u4e4b\u9593\u9032\u884c\u8f49\u63db\uff0c\u5f9e\u800c\u63d0\u9ad8\u6578\u64da\u8655\u7406\u7684\u9748\u6d3b\u6027\u548c\u6548\u7387\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0eOracle\u7684\u6578\u64da\u8f49\u63db\u51fd\u6578\uff0c\u5305\u62ec\u5176\u7528\u9014\u3001\u5e38\u898b\u7684\u51fd\u6578\u53ca\u5176\u793a\u4f8b\u3002<\/p>\n<h2 id=\"%e6%95%b8%e6%93%9a%e8%bd%89%e6%8f%9b%e5%87%bd%e6%95%b8%e7%9a%84%e7%94%a8%e9%80%94-etNRfQonpj\">\u6578\u64da\u8f49\u63db\u51fd\u6578\u7684\u7528\u9014<\/h2>\n<p>\u6578\u64da\u8f49\u63db\u51fd\u6578\u7684\u4e3b\u8981\u7528\u9014\u662f\u5c07\u4e00\u7a2e\u6578\u64da\u985e\u578b\u8f49\u63db\u70ba\u53e6\u4e00\u7a2e\u6578\u64da\u985e\u578b\u3002\u9019\u5728\u6578\u64da\u5eab\u64cd\u4f5c\u4e2d\u975e\u5e38\u5e38\u898b\uff0c\u56e0\u70ba\u4e0d\u540c\u7684\u6578\u64da\u985e\u578b\u53ef\u80fd\u9700\u8981\u9032\u884c\u6bd4\u8f03\u3001\u8a08\u7b97\u6216\u986f\u793a\u3002\u4f7f\u7528\u9019\u4e9b\u51fd\u6578\u53ef\u4ee5\u78ba\u4fdd\u6578\u64da\u7684\u6b63\u78ba\u6027\u548c\u4e00\u81f4\u6027\uff0c\u4e26\u907f\u514d\u56e0\u6578\u64da\u985e\u578b\u4e0d\u5339\u914d\u800c\u5c0e\u81f4\u7684\u932f\u8aa4\u3002<\/p>\n<h2 id=\"%e5%b8%b8%e8%a6%8b%e7%9a%84oracle%e6%95%b8%e6%93%9a%e8%bd%89%e6%8f%9b%e5%87%bd%e6%95%b8-etNRfQonpj\">\u5e38\u898b\u7684Oracle\u6578\u64da\u8f49\u63db\u51fd\u6578<\/h2>\n<h3 id=\"1-to_char-etNRfQonpj\">1. TO_CHAR<\/h3>\n<p>TO_CHAR\u51fd\u6578\u7528\u65bc\u5c07\u6578\u5b57\u6216\u65e5\u671f\u8f49\u63db\u70ba\u5b57\u7b26\u578b\u6578\u64da\u3002\u9019\u5728\u9700\u8981\u5c07\u6578\u64da\u4ee5\u7279\u5b9a\u683c\u5f0f\u986f\u793a\u6642\u975e\u5e38\u6709\u7528\u3002<\/p>\n<pre><code>SELECT TO_CHAR(SYSDATE, 'YYYY-MM-DD') AS formatted_date FROM dual;<\/code><\/pre>\n<p>\u4e0a\u8ff0\u67e5\u8a62\u5c07\u7576\u524d\u65e5\u671f\u8f49\u63db\u70ba&#8217;YYYY-MM-DD&#8217;\u683c\u5f0f\u7684\u5b57\u7b26\u4e32\u3002<\/p>\n<h3 id=\"2-to_number-etNRfQonpj\">2. TO_NUMBER<\/h3>\n<p>TO_NUMBER\u51fd\u6578\u7528\u65bc\u5c07\u5b57\u7b26\u578b\u6578\u64da\u8f49\u63db\u70ba\u6578\u5b57\u578b\u6578\u64da\u3002\u9019\u5728\u9700\u8981\u9032\u884c\u6578\u5b78\u8a08\u7b97\u6642\u975e\u5e38\u91cd\u8981\u3002<\/p>\n<pre><code>SELECT TO_NUMBER('12345.67') AS numeric_value FROM dual;<\/code><\/pre>\n<p>\u9019\u500b\u67e5\u8a62\u5c07\u5b57\u7b26\u4e32&#8217;12345.67&#8217;\u8f49\u63db\u70ba\u6578\u5b57\u578b\u6578\u64da\u3002<\/p>\n<h3 id=\"3-to_date-etNRfQonpj\">3. TO_DATE<\/h3>\n<p>TO_DATE\u51fd\u6578\u7528\u65bc\u5c07\u5b57\u7b26\u578b\u6578\u64da\u8f49\u63db\u70ba\u65e5\u671f\u578b\u6578\u64da\u3002\u9019\u5728\u8655\u7406\u65e5\u671f\u548c\u6642\u9593\u6578\u64da\u6642\u975e\u5e38\u6709\u7528\u3002<\/p>\n<pre><code>SELECT TO_DATE('2023-10-01', 'YYYY-MM-DD') AS date_value FROM dual;<\/code><\/pre>\n<p>\u9019\u500b\u67e5\u8a62\u5c07\u5b57\u7b26\u4e32&#8217;2023-10-01&#8217;\u8f49\u63db\u70ba\u65e5\u671f\u578b\u6578\u64da\u3002<\/p>\n<h3 id=\"4-cast-etNRfQonpj\">4. CAST<\/h3>\n<p>CAST\u51fd\u6578\u662f\u4e00\u500b\u901a\u7528\u7684\u6578\u64da\u8f49\u63db\u51fd\u6578\uff0c\u53ef\u4ee5\u5c07\u4e00\u500b\u8868\u9054\u5f0f\u8f49\u63db\u70ba\u6307\u5b9a\u7684\u6578\u64da\u985e\u578b\u3002<\/p>\n<pre><code>SELECT CAST('12345' AS NUMBER) AS numeric_value FROM dual;<\/code><\/pre>\n<p>\u9019\u500b\u67e5\u8a62\u5c07\u5b57\u7b26\u4e32&#8217;12345&#8217;\u8f49\u63db\u70ba\u6578\u5b57\u578b\u6578\u64da\u3002<\/p>\n<h2 id=\"%e4%bd%bf%e7%94%a8%e6%95%b8%e6%93%9a%e8%bd%89%e6%8f%9b%e5%87%bd%e6%95%b8%e7%9a%84%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-etNRfQonpj\">\u4f7f\u7528\u6578\u64da\u8f49\u63db\u51fd\u6578\u7684\u6ce8\u610f\u4e8b\u9805<\/h2>\n<ul>\n<li><strong>\u6578\u64da\u985e\u578b\u517c\u5bb9\u6027\uff1a<\/strong>\u5728\u9032\u884c\u6578\u64da\u8f49\u63db\u6642\uff0c\u5fc5\u9808\u78ba\u4fdd\u6e90\u6578\u64da\u985e\u578b\u548c\u76ee\u6a19\u6578\u64da\u985e\u578b\u4e4b\u9593\u7684\u517c\u5bb9\u6027\uff0c\u5426\u5247\u53ef\u80fd\u6703\u5c0e\u81f4\u932f\u8aa4\u3002<\/li>\n<li><strong>\u683c\u5f0f\u5316\u554f\u984c\uff1a<\/strong>\u5728\u4f7f\u7528TO_CHAR\u548cTO_DATE\u7b49\u51fd\u6578\u6642\uff0c\u5fc5\u9808\u6b63\u78ba\u6307\u5b9a\u683c\u5f0f\uff0c\u5426\u5247\u53ef\u80fd\u6703\u5f97\u5230\u610f\u5916\u7684\u7d50\u679c\u3002<\/li>\n<li><strong>\u6027\u80fd\u8003\u91cf\uff1a<\/strong>\u904e\u5ea6\u4f7f\u7528\u6578\u64da\u8f49\u63db\u51fd\u6578\u53ef\u80fd\u6703\u5f71\u97ff\u67e5\u8a62\u6027\u80fd\uff0c\u56e0\u6b64\u61c9\u8b39\u614e\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-etNRfQonpj\">\u7e3d\u7d50<\/h2>\n<p>Oracle\u7684\u6578\u64da\u8f49\u63db\u51fd\u6578\u5728\u6578\u64da\u8655\u7406\u4e2d\u626e\u6f14\u8457\u91cd\u8981\u89d2\u8272\uff0c\u80fd\u5920\u5e6b\u52a9\u7528\u6236\u5728\u4e0d\u540c\u6578\u64da\u985e\u578b\u4e4b\u9593\u9032\u884c\u9748\u6d3b\u7684\u8f49\u63db\u3002\u4e86\u89e3\u9019\u4e9b\u51fd\u6578\u7684\u4f7f\u7528\u65b9\u6cd5\u548c\u6ce8\u610f\u4e8b\u9805\uff0c\u5c07\u6709\u52a9\u65bc\u63d0\u9ad8\u6578\u64da\u5eab\u64cd\u4f5c\u7684\u6548\u7387\u548c\u6e96\u78ba\u6027\u3002\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<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u63a2\u7d22Oracle\u6578\u64da\u8f49\u63db\u51fd\u6578\u7684\u529f\u80fd\u8207\u61c9\u7528\uff0c\u63d0\u5347\u6578\u64da\u8655\u7406\u6548\u7387\uff0c\u52a9\u60a8\u8f15\u9b06\u7ba1\u7406\u548c\u8f49\u63db\u6578\u64da\u683c\u5f0f\u3002<\/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-153739","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/153739","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=153739"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/153739\/revisions"}],"predecessor-version":[{"id":153740,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/153739\/revisions\/153740"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=153739"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=153739"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=153739"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}