{"id":160275,"date":"2024-11-03T21:44:21","date_gmt":"2024-11-03T13:44:21","guid":{"rendered":"https:\/\/server.hk\/cnblog\/160275\/"},"modified":"2024-11-03T21:44:23","modified_gmt":"2024-11-03T13:44:23","slug":"oceanbase-%e6%95%99%e7%a8%8b%ef%bc%9aoceanbase-to_number","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/160275\/","title":{"rendered":"OceanBase \u6559\u7a0b\uff1aOceanBase TO_NUMBER"},"content":{"rendered":"<h1 id=\"oceanbase-%e6%95%99%e7%a8%8b%ef%bc%9aoceanbase-to_number-XTOVdYDczD\">OceanBase \u6559\u7a0b\uff1aOceanBase TO_NUMBER<\/h1>\n<p>\u5728\u7576\u4eca\u7684\u6578\u64da\u5eab\u7ba1\u7406\u7cfb\u7d71\u4e2d\uff0cOceanBase \u4f5c\u70ba\u4e00\u500b\u9ad8\u6027\u80fd\u7684\u5206\u4f48\u5f0f\u6578\u64da\u5eab\uff0c\u8d8a\u4f86\u8d8a\u53d7\u5230\u958b\u767c\u8005\u548c\u4f01\u696d\u7684\u9752\u775e\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e OceanBase \u4e2d\u7684 TO_NUMBER \u51fd\u6578\uff0c\u5e6b\u52a9\u8b80\u8005\u7406\u89e3\u5176\u7528\u6cd5\u53ca\u61c9\u7528\u5834\u666f\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-to_number-%e5%87%bd%e6%95%b8%ef%bc%9f-XTOVdYDczD\">\u4ec0\u9ebc\u662f TO_NUMBER \u51fd\u6578\uff1f<\/h2>\n<p>TO_NUMBER \u51fd\u6578\u662f\u4e00\u500b\u7528\u65bc\u5c07\u5b57\u7b26\u4e32\u8f49\u63db\u70ba\u6578\u5b57\u7684\u51fd\u6578\u3002\u5728 OceanBase \u4e2d\uff0c\u9019\u500b\u51fd\u6578\u53ef\u4ee5\u5e6b\u52a9\u7528\u6236\u5c07\u5b58\u5132\u70ba\u5b57\u7b26\u4e32\u7684\u6578\u5b57\u6578\u64da\u8f49\u63db\u70ba\u6578\u5b57\u985e\u578b\uff0c\u4ee5\u4fbf\u9032\u884c\u6578\u5b78\u904b\u7b97\u6216\u9032\u4e00\u6b65\u7684\u6578\u64da\u8655\u7406\u3002<\/p>\n<h2 id=\"to_number-%e5%87%bd%e6%95%b8%e7%9a%84%e8%aa%9e%e6%b3%95-XTOVdYDczD\">TO_NUMBER \u51fd\u6578\u7684\u8a9e\u6cd5<\/h2>\n<pre><code>TO_NUMBER(string, [format_mask], [nls_language])<\/code><\/pre>\n<ul>\n<li><strong>string<\/strong>\uff1a\u8981\u8f49\u63db\u7684\u5b57\u7b26\u4e32\u3002<\/li>\n<li><strong>format_mask<\/strong>\uff1a\u53ef\u9078\uff0c\u6307\u5b9a\u5b57\u7b26\u4e32\u7684\u683c\u5f0f\u3002\u5982\u679c\u4e0d\u63d0\u4f9b\uff0c\u5247\u4f7f\u7528\u9ed8\u8a8d\u683c\u5f0f\u3002<\/li>\n<li><strong>nls_language<\/strong>\uff1a\u53ef\u9078\uff0c\u6307\u5b9a\u8a9e\u8a00\u74b0\u5883\u3002<\/li>\n<\/ul>\n<h2 id=\"to_number-%e5%87%bd%e6%95%b8%e7%9a%84%e4%bd%bf%e7%94%a8%e7%a4%ba%e4%be%8b-XTOVdYDczD\">TO_NUMBER \u51fd\u6578\u7684\u4f7f\u7528\u793a\u4f8b<\/h2>\n<p>\u4ee5\u4e0b\u662f\u4e00\u4e9b\u4f7f\u7528 TO_NUMBER \u51fd\u6578\u7684\u793a\u4f8b\uff0c\u5e6b\u52a9\u8b80\u8005\u66f4\u597d\u5730\u7406\u89e3\u5176\u7528\u6cd5\u3002<\/p>\n<h3 id=\"%e7%a4%ba%e4%be%8b-1%ef%bc%9a%e5%9f%ba%e6%9c%ac%e7%94%a8%e6%b3%95-XTOVdYDczD\">\u793a\u4f8b 1\uff1a\u57fa\u672c\u7528\u6cd5<\/h3>\n<pre><code>SELECT TO_NUMBER('12345') AS number_value;<\/code><\/pre>\n<p>\u9019\u500b\u67e5\u8a62\u5c07\u5b57\u7b26\u4e32 &#8216;12345&#8217; \u8f49\u63db\u70ba\u6578\u5b57 12345\uff0c\u7d50\u679c\u5c07\u986f\u793a\u5728 number_value \u5217\u4e2d\u3002<\/p>\n<h3 id=\"%e7%a4%ba%e4%be%8b-2%ef%bc%9a%e4%bd%bf%e7%94%a8%e6%a0%bc%e5%bc%8f%e6%8e%a9%e7%a2%bc-XTOVdYDczD\">\u793a\u4f8b 2\uff1a\u4f7f\u7528\u683c\u5f0f\u63a9\u78bc<\/h3>\n<pre><code>SELECT TO_NUMBER('1,234.56', '9,999.99') AS formatted_number;<\/code><\/pre>\n<p>\u5728\u9019\u500b\u793a\u4f8b\u4e2d\uff0c\u5b57\u7b26\u4e32 &#8216;1,234.56&#8217; \u88ab\u8f49\u63db\u70ba\u6578\u5b57 1234.56\uff0c\u4f7f\u7528\u4e86\u683c\u5f0f\u63a9\u78bc &#8216;9,999.99&#8217; \u4f86\u6307\u5b9a\u6578\u5b57\u7684\u683c\u5f0f\u3002<\/p>\n<h3 id=\"%e7%a4%ba%e4%be%8b-3%ef%bc%9a%e8%99%95%e7%90%86%e7%84%a1%e6%95%88%e6%95%b8%e6%93%9a-XTOVdYDczD\">\u793a\u4f8b 3\uff1a\u8655\u7406\u7121\u6548\u6578\u64da<\/h3>\n<pre><code>SELECT TO_NUMBER('abc') AS invalid_number;<\/code><\/pre>\n<p>\u5982\u679c\u5617\u8a66\u5c07\u7121\u6cd5\u8f49\u63db\u7684\u5b57\u7b26\u4e32\uff08\u5982 &#8216;abc&#8217;\uff09\u8f49\u63db\u70ba\u6578\u5b57\uff0cOceanBase \u5c07\u8fd4\u56de\u932f\u8aa4\u3002\u9019\u63d0\u9192\u958b\u767c\u8005\u5728\u4f7f\u7528 TO_NUMBER \u51fd\u6578\u6642\uff0c\u61c9\u8a72\u78ba\u4fdd\u8f38\u5165\u7684\u5b57\u7b26\u4e32\u662f\u6709\u6548\u7684\u6578\u5b57\u683c\u5f0f\u3002<\/p>\n<h2 id=\"to_number-%e5%87%bd%e6%95%b8%e7%9a%84%e6%87%89%e7%94%a8%e5%a0%b4%e6%99%af-XTOVdYDczD\">TO_NUMBER \u51fd\u6578\u7684\u61c9\u7528\u5834\u666f<\/h2>\n<p>TO_NUMBER \u51fd\u6578\u5728\u8a31\u591a\u5834\u666f\u4e2d\u90fd\u975e\u5e38\u6709\u7528\uff0c\u7279\u5225\u662f\u5728\u6578\u64da\u6e05\u7406\u548c\u8f49\u63db\u904e\u7a0b\u4e2d\u3002\u4ee5\u4e0b\u662f\u4e00\u4e9b\u5e38\u898b\u7684\u61c9\u7528\u5834\u666f\uff1a<\/p>\n<ul>\n<li><strong>\u6578\u64da\u5c0e\u5165\uff1a<\/strong>\u5728\u5c07\u6578\u64da\u5f9e\u5916\u90e8\u7cfb\u7d71\u5c0e\u5165 OceanBase \u6642\uff0c\u53ef\u80fd\u6703\u9047\u5230\u5b57\u7b26\u4e32\u683c\u5f0f\u7684\u6578\u5b57\u3002\u4f7f\u7528 TO_NUMBER \u51fd\u6578\u53ef\u4ee5\u8f15\u9b06\u5c07\u5176\u8f49\u63db\u70ba\u6578\u5b57\u985e\u578b\u3002<\/li>\n<li><strong>\u5831\u544a\u751f\u6210\uff1a<\/strong>\u5728\u751f\u6210\u5831\u544a\u6642\uff0c\u53ef\u80fd\u9700\u8981\u5c0d\u5b57\u7b26\u4e32\u683c\u5f0f\u7684\u6578\u5b57\u9032\u884c\u8a08\u7b97\u3002TO_NUMBER \u51fd\u6578\u53ef\u4ee5\u5e6b\u52a9\u9032\u884c\u9019\u4e9b\u8a08\u7b97\u3002<\/li>\n<li><strong>\u6578\u64da\u9a57\u8b49\uff1a<\/strong>\u5728\u6578\u64da\u9a57\u8b49\u904e\u7a0b\u4e2d\uff0c\u53ef\u4ee5\u4f7f\u7528 TO_NUMBER \u51fd\u6578\u6aa2\u67e5\u5b57\u7b26\u4e32\u662f\u5426\u80fd\u5920\u6210\u529f\u8f49\u63db\u70ba\u6578\u5b57\uff0c\u5f9e\u800c\u78ba\u4fdd\u6578\u64da\u7684\u6709\u6548\u6027\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b8%bd%e7%b5%90-XTOVdYDczD\">\u7e3d\u7d50<\/h2>\n<p>TO_NUMBER \u51fd\u6578\u5728 OceanBase \u4e2d\u662f\u4e00\u500b\u5f37\u5927\u7684\u5de5\u5177\uff0c\u80fd\u5920\u5e6b\u52a9\u958b\u767c\u8005\u5c07\u5b57\u7b26\u4e32\u8f49\u63db\u70ba\u6578\u5b57\uff0c\u5f9e\u800c\u9032\u884c\u66f4\u8907\u96dc\u7684\u6578\u64da\u8655\u7406\u548c\u5206\u6790\u3002\u7121\u8ad6\u662f\u5728\u6578\u64da\u5c0e\u5165\u3001\u5831\u544a\u751f\u6210\u9084\u662f\u6578\u64da\u9a57\u8b49\u4e2d\uff0cTO_NUMBER \u51fd\u6578\u90fd\u80fd\u767c\u63ee\u91cd\u8981\u4f5c\u7528\u3002\u5982\u679c\u60a8\u6b63\u5728\u5c0b\u627e\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">VPS<\/a> \u89e3\u6c7a\u65b9\u6848\u4f86\u904b\u884c OceanBase\uff0cServer.HK \u63d0\u4f9b\u4e86\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>Learn how to use the TO_NUMBER function in OceanBase with this comprehensive tutorial, enhancing your data manipulation skills effectively.<\/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-160275","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160275","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=160275"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160275\/revisions"}],"predecessor-version":[{"id":160276,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/160275\/revisions\/160276"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=160275"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=160275"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=160275"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}