{"id":94948,"date":"2024-10-19T20:58:15","date_gmt":"2024-10-19T12:58:15","guid":{"rendered":"https:\/\/server.hk\/cnblog\/94948\/"},"modified":"2024-10-19T20:58:16","modified_gmt":"2024-10-19T12:58:16","slug":"oracle%e6%9f%a5%e8%a9%a2%e8%bd%89%e6%8f%9b%e7%82%basql%e6%9f%a5%e8%a9%a2-%e6%95%b8%e5%ad%97%e8%bd%89%e6%8f%9b","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/94948\/","title":{"rendered":"Oracle\u67e5\u8a62\u8f49\u63db\u70baSQL\u67e5\u8a62&#8211;\u6578\u5b57\u8f49\u63db"},"content":{"rendered":"<h1 id=\"oracle%e6%9f%a5%e8%a9%a2%e8%bd%89%e6%8f%9b%e7%82%basql%e6%9f%a5%e8%a9%a2-%e6%95%b8%e5%ad%97%e8%bd%89%e6%8f%9b-OWSjdfrhKc\">Oracle\u67e5\u8a62\u8f49\u63db\u70baSQL\u67e5\u8a62&#8211;\u6578\u5b57\u8f49\u63db<\/h1>\n<p>\u5728\u6578\u64da\u5eab\u7ba1\u7406\u4e2d\uff0cOracle\u548cSQL Server\u662f\u5169\u500b\u5ee3\u6cdb\u4f7f\u7528\u7684\u6578\u64da\u5eab\u7cfb\u7d71\u3002\u96d6\u7136\u5b83\u5011\u7684\u57fa\u672c\u529f\u80fd\u76f8\u4f3c\uff0c\u4f46\u5728\u67e5\u8a62\u8a9e\u8a00\u7684\u8a9e\u6cd5\u548c\u529f\u80fd\u4e0a\u537b\u5b58\u5728\u4e00\u4e9b\u5dee\u7570\u3002\u672c\u6587\u5c07\u63a2\u8a0e\u5982\u4f55\u5c07Oracle\u67e5\u8a62\u8f49\u63db\u70baSQL\u67e5\u8a62\uff0c\u7279\u5225\u662f\u5728\u6578\u5b57\u8f49\u63db\u65b9\u9762\u7684\u5177\u9ad4\u5be6\u73fe\u3002<\/p>\n<h2 id=\"%e6%95%b8%e5%ad%97%e8%bd%89%e6%8f%9b%e7%9a%84%e5%bf%85%e8%a6%81%e6%80%a7-OWSjdfrhKc\">\u6578\u5b57\u8f49\u63db\u7684\u5fc5\u8981\u6027<\/h2>\n<p>\u5728\u6578\u64da\u8655\u7406\u904e\u7a0b\u4e2d\uff0c\u6578\u5b57\u8f49\u63db\u662f\u5e38\u898b\u7684\u9700\u6c42\u3002\u4f8b\u5982\uff0c\u7576\u5f9eOracle\u6578\u64da\u5eab\u4e2d\u63d0\u53d6\u6578\u64da\u6642\uff0c\u53ef\u80fd\u9700\u8981\u5c07\u67d0\u4e9b\u6578\u64da\u985e\u578b\u8f49\u63db\u70baSQL Server\u6240\u652f\u6301\u7684\u683c\u5f0f\u3002\u9019\u4e0d\u50c5\u6709\u52a9\u65bc\u6578\u64da\u7684\u6b63\u78ba\u6027\uff0c\u9084\u80fd\u63d0\u9ad8\u67e5\u8a62\u7684\u6548\u7387\u3002<\/p>\n<h2 id=\"oracle%e4%b8%ad%e7%9a%84%e6%95%b8%e5%ad%97%e8%bd%89%e6%8f%9b-OWSjdfrhKc\">Oracle\u4e2d\u7684\u6578\u5b57\u8f49\u63db<\/h2>\n<p>\u5728Oracle\u4e2d\uff0c\u6578\u5b57\u8f49\u63db\u901a\u5e38\u4f7f\u7528\u4ee5\u4e0b\u51fd\u6578\uff1a<\/p>\n<ul>\n<li><code>TO_NUMBER<\/code>\uff1a\u5c07\u5b57\u7b26\u4e32\u8f49\u63db\u70ba\u6578\u5b57\u3002<\/li>\n<li><code>TO_CHAR<\/code>\uff1a\u5c07\u6578\u5b57\u8f49\u63db\u70ba\u5b57\u7b26\u4e32\u3002<\/li>\n<li><code>CAST<\/code>\uff1a\u5c07\u4e00\u7a2e\u6578\u64da\u985e\u578b\u8f49\u63db\u70ba\u53e6\u4e00\u7a2e\u6578\u64da\u985e\u578b\u3002<\/li>\n<\/ul>\n<p>\u4f8b\u5982\uff0c\u4ee5\u4e0b\u662fOracle\u4e2d\u4f7f\u7528<code>TO_NUMBER<\/code>\u51fd\u6578\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code>SELECT TO_NUMBER('123.45') AS converted_number FROM dual;<\/code><\/pre>\n<h2 id=\"sql-server%e4%b8%ad%e7%9a%84%e6%95%b8%e5%ad%97%e8%bd%89%e6%8f%9b-OWSjdfrhKc\">SQL Server\u4e2d\u7684\u6578\u5b57\u8f49\u63db<\/h2>\n<p>\u5728SQL Server\u4e2d\uff0c\u6578\u5b57\u8f49\u63db\u5247\u4f7f\u7528\u4e0d\u540c\u7684\u51fd\u6578\uff0c\u5982\u4e0b\u6240\u793a\uff1a<\/p>\n<ul>\n<li><code>CAST<\/code>\uff1a\u5c07\u4e00\u7a2e\u6578\u64da\u985e\u578b\u8f49\u63db\u70ba\u53e6\u4e00\u7a2e\u6578\u64da\u985e\u578b\u3002<\/li>\n<li><code>CONVERT<\/code>\uff1a\u63d0\u4f9b\u66f4\u9748\u6d3b\u7684\u6578\u64da\u985e\u578b\u8f49\u63db\u3002<\/li>\n<\/ul>\n<p>\u4ee5\u4e0b\u662fSQL Server\u4e2d\u4f7f\u7528<code>CAST<\/code>\u51fd\u6578\u7684\u793a\u4f8b\uff1a<\/p>\n<pre><code>SELECT CAST('123.45' AS FLOAT) AS converted_number;<\/code><\/pre>\n<h2 id=\"oracle%e6%9f%a5%e8%a9%a2%e8%bd%89%e6%8f%9b%e7%82%basql%e6%9f%a5%e8%a9%a2%e7%9a%84%e7%a4%ba%e4%be%8b-OWSjdfrhKc\">Oracle\u67e5\u8a62\u8f49\u63db\u70baSQL\u67e5\u8a62\u7684\u793a\u4f8b<\/h2>\n<p>\u5047\u8a2d\u6211\u5011\u6709\u4e00\u500bOracle\u67e5\u8a62\uff0c\u8a72\u67e5\u8a62\u5f9e\u4e00\u500b\u8868\u4e2d\u63d0\u53d6\u6578\u5b57\u4e26\u9032\u884c\u8f49\u63db\uff1a<\/p>\n<pre><code>SELECT TO_NUMBER(column_name) AS converted_number FROM table_name;<\/code><\/pre>\n<p>\u5728SQL Server\u4e2d\uff0c\u9019\u500b\u67e5\u8a62\u53ef\u4ee5\u8f49\u63db\u70ba\uff1a<\/p>\n<pre><code>SELECT CAST(column_name AS FLOAT) AS converted_number FROM table_name;<\/code><\/pre>\n<h2 id=\"%e6%b3%a8%e6%84%8f%e4%ba%8b%e9%a0%85-OWSjdfrhKc\">\u6ce8\u610f\u4e8b\u9805<\/h2>\n<p>\u5728\u9032\u884c\u6578\u5b57\u8f49\u63db\u6642\uff0c\u958b\u767c\u8005\u9700\u8981\u6ce8\u610f\u4ee5\u4e0b\u5e7e\u9ede\uff1a<\/p>\n<ul>\n<li>\u78ba\u4fdd\u6578\u64da\u683c\u5f0f\u6b63\u78ba\uff1a\u5728\u9032\u884c\u8f49\u63db\u4e4b\u524d\uff0c\u61c9\u6aa2\u67e5\u6578\u64da\u662f\u5426\u7b26\u5408\u9810\u671f\u683c\u5f0f\uff0c\u4ee5\u907f\u514d\u8f49\u63db\u932f\u8aa4\u3002<\/li>\n<li>\u8003\u616e\u6578\u64da\u7bc4\u570d\uff1a\u4e0d\u540c\u7684\u6578\u64da\u985e\u578b\u6709\u4e0d\u540c\u7684\u7bc4\u570d\uff0c\u61c9\u6839\u64da\u5be6\u969b\u9700\u6c42\u9078\u64c7\u5408\u9069\u7684\u6578\u64da\u985e\u578b\u3002<\/li>\n<li>\u6027\u80fd\u5f71\u97ff\uff1a\u904e\u591a\u7684\u6578\u64da\u8f49\u63db\u53ef\u80fd\u6703\u5f71\u97ff\u67e5\u8a62\u6027\u80fd\uff0c\u61c9\u8b39\u614e\u4f7f\u7528\u3002<\/li>\n<\/ul>\n<h2 id=\"%e7%b5%90%e8%ab%96-OWSjdfrhKc\">\u7d50\u8ad6<\/h2>\n<p>\u5c07Oracle\u67e5\u8a62\u8f49\u63db\u70baSQL\u67e5\u8a62\uff0c\u7279\u5225\u662f\u5728\u6578\u5b57\u8f49\u63db\u65b9\u9762\uff0c\u96d6\u7136\u5b58\u5728\u8a9e\u6cd5\u4e0a\u7684\u5dee\u7570\uff0c\u4f46\u901a\u904e\u6b63\u78ba\u7684\u51fd\u6578\u4f7f\u7528\uff0c\u53ef\u4ee5\u6709\u6548\u5730\u5be6\u73fe\u6578\u64da\u7684\u8f49\u63db\u548c\u8655\u7406\u3002\u4e86\u89e3\u9019\u4e9b\u5dee\u7570\u4e0d\u50c5\u6709\u52a9\u65bc\u958b\u767c\u8005\u5728\u4e0d\u540c\u7684\u6578\u64da\u5eab\u7cfb\u7d71\u4e4b\u9593\u9032\u884c\u9077\u79fb\uff0c\u9084\u80fd\u63d0\u9ad8\u6578\u64da\u8655\u7406\u7684\u6548\u7387\u3002<\/p>\n<p>\u5982\u9700\u4e86\u89e3\u66f4\u591a\u6709\u95dc<code><a href=\"https:\/\/server.hk\">VPS<\/a><\/code>\u548c<code><a href=\"https:\/\/server.hk\">\u9999\u6e2f\u4f3a\u670d\u5668<\/a><\/code>\u7684\u8cc7\u8a0a\uff0c\u8acb\u8a2a\u554f\u6211\u5011\u7684\u7db2\u7ad9\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u5b78\u7fd2\u5982\u4f55\u5c07Oracle\u67e5\u8a62\u8f49\u63db\u70baSQL\u67e5\u8a62\uff0c\u5c08\u6ce8\u65bc\u6578\u5b57\u8f49\u63db\u6280\u5de7\uff0c\u63d0\u5347\u6578\u64da\u8655\u7406\u6548\u7387\u8207\u6e96\u78ba\u6027\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-94948","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/94948","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=94948"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/94948\/revisions"}],"predecessor-version":[{"id":94949,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/94948\/revisions\/94949"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=94948"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=94948"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=94948"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}