{"id":84995,"date":"2024-10-17T12:30:17","date_gmt":"2024-10-17T04:30:17","guid":{"rendered":"https:\/\/server.hk\/cnblog\/84995\/"},"modified":"2024-10-17T12:30:17","modified_gmt":"2024-10-17T04:30:17","slug":"ora-12702-%e5%9c%a8-sql-%e5%87%bd%e6%95%b8%e4%b8%ad%e4%bd%bf%e7%94%a8%e7%9a%84%e7%84%a1%e6%95%88-nls-%e5%8f%83%e6%95%b8%e5%ad%97%e7%ac%a6%e4%b8%b2%e3%80%82oracle-%e5%a0%b1%e9%8c%af-%e6%95%85%e9%9a%9c","status":"publish","type":"post","link":"https:\/\/server.hk\/cnblog\/84995\/","title":{"rendered":"ORA-12702: \u5728 SQL \u51fd\u6578\u4e2d\u4f7f\u7528\u7684\u7121\u6548 NLS \u53c3\u6578\u5b57\u7b26\u4e32\u3002ORACLE \u5831\u932f \u6545\u969c\u4fee\u5fa9 \u9060\u7a0b\u8655\u7406"},"content":{"rendered":"<h1 id=\"ora-12702-%e5%9c%a8-sql-%e5%87%bd%e6%95%b8%e4%b8%ad%e4%bd%bf%e7%94%a8%e7%9a%84%e7%84%a1%e6%95%88-nls-%e5%8f%83%e6%95%b8%e5%ad%97%e7%ac%a6%e4%b8%b2-GYFQTnCsqP\">ORA-12702: \u5728 SQL \u51fd\u6578\u4e2d\u4f7f\u7528\u7684\u7121\u6548 NLS \u53c3\u6578\u5b57\u7b26\u4e32<\/h1>\n<p>\u5728\u4f7f\u7528 Oracle \u6578\u64da\u5eab\u6642\uff0c\u958b\u767c\u8005\u548c\u6578\u64da\u5eab\u7ba1\u7406\u54e1\u53ef\u80fd\u6703\u9047\u5230\u5404\u7a2e\u932f\u8aa4\u4ee3\u78bc\uff0c\u5176\u4e2d\u4e4b\u4e00\u4fbf\u662f <code>ORA-12702<\/code>\u3002\u9019\u500b\u932f\u8aa4\u901a\u5e38\u8868\u793a\u5728 SQL \u51fd\u6578\u4e2d\u4f7f\u7528\u4e86\u7121\u6548\u7684 NLS\uff08National Language Support\uff09\u53c3\u6578\u5b57\u7b26\u4e32\u3002\u672c\u6587\u5c07\u6df1\u5165\u63a2\u8a0e\u9019\u500b\u932f\u8aa4\u7684\u539f\u56e0\u3001\u5f71\u97ff\u4ee5\u53ca\u5982\u4f55\u9032\u884c\u6545\u969c\u4fee\u5fa9\u3002<\/p>\n<h2 id=\"%e4%bb%80%e9%ba%bc%e6%98%af-nls-%e5%8f%83%e6%95%b8%ef%bc%9f-GYFQTnCsqP\">\u4ec0\u9ebc\u662f NLS \u53c3\u6578\uff1f<\/h2>\n<p>NLS \u53c3\u6578\u662f Oracle \u6578\u64da\u5eab\u7528\u4f86\u652f\u6301\u591a\u8a9e\u8a00\u548c\u5730\u5340\u7279\u5b9a\u7684\u6578\u64da\u683c\u5f0f\u7684\u8a2d\u7f6e\u3002\u9019\u4e9b\u53c3\u6578\u5305\u62ec\u65e5\u671f\u683c\u5f0f\u3001\u6578\u5b57\u683c\u5f0f\u3001\u8ca8\u5e63\u7b26\u865f\u7b49\u3002\u7576 SQL \u67e5\u8a62\u6216 PL\/SQL \u7a0b\u5e8f\u4e2d\u4f7f\u7528\u4e86\u4e0d\u6b63\u78ba\u7684 NLS \u53c3\u6578\u6642\uff0c\u5c31\u53ef\u80fd\u5c0e\u81f4 <code>ORA-12702<\/code> \u932f\u8aa4\u3002<\/p>\n<h2 id=\"ora-12702-%e9%8c%af%e8%aa%a4%e7%9a%84%e5%8e%9f%e5%9b%a0-GYFQTnCsqP\">ORA-12702 \u932f\u8aa4\u7684\u539f\u56e0<\/h2>\n<p>\u9019\u500b\u932f\u8aa4\u901a\u5e38\u7531\u4ee5\u4e0b\u5e7e\u500b\u539f\u56e0\u5f15\u8d77\uff1a<\/p>\n<ul>\n<li><strong>\u7121\u6548\u7684 NLS \u53c3\u6578\u503c\uff1a<\/strong>\u5982\u679c\u5728 SQL \u67e5\u8a62\u4e2d\u4f7f\u7528\u4e86\u4e0d\u652f\u6301\u7684 NLS \u53c3\u6578\u503c\uff0c\u5247\u6703\u5c0e\u81f4\u6b64\u932f\u8aa4\u3002<\/li>\n<li><strong>\u5b57\u7b26\u96c6\u4e0d\u5339\u914d\uff1a<\/strong>\u7576\u6578\u64da\u5eab\u7684\u5b57\u7b26\u96c6\u8207\u61c9\u7528\u7a0b\u5e8f\u7684\u5b57\u7b26\u96c6\u4e0d\u4e00\u81f4\u6642\uff0c\u53ef\u80fd\u6703\u51fa\u73fe\u6b64\u932f\u8aa4\u3002<\/li>\n<li><strong>\u74b0\u5883\u8b8a\u91cf\u8a2d\u7f6e\u932f\u8aa4\uff1a<\/strong>\u5982\u679c\u64cd\u4f5c\u7cfb\u7d71\u7684\u74b0\u5883\u8b8a\u91cf\u8a2d\u7f6e\u4e0d\u6b63\u78ba\uff0c\u53ef\u80fd\u6703\u5f71\u97ff NLS \u53c3\u6578\u7684\u89e3\u6790\u3002<\/li>\n<\/ul>\n<h2 id=\"%e5%a6%82%e4%bd%95%e4%bf%ae%e5%be%a9-ora-12702-%e9%8c%af%e8%aa%a4-GYFQTnCsqP\">\u5982\u4f55\u4fee\u5fa9 ORA-12702 \u932f\u8aa4<\/h2>\n<p>\u4fee\u5fa9 <code>ORA-12702<\/code> \u932f\u8aa4\u7684\u6b65\u9a5f\u5982\u4e0b\uff1a<\/p>\n<h3 id=\"1-%e6%aa%a2%e6%9f%a5-nls-%e5%8f%83%e6%95%b8%e8%a8%ad%e7%bd%ae-GYFQTnCsqP\">1. \u6aa2\u67e5 NLS \u53c3\u6578\u8a2d\u7f6e<\/h3>\n<p>\u9996\u5148\uff0c\u60a8\u9700\u8981\u6aa2\u67e5\u6578\u64da\u5eab\u7684 NLS \u53c3\u6578\u8a2d\u7f6e\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b SQL \u67e5\u8a62\u4f86\u67e5\u770b\u7576\u524d\u7684 NLS \u53c3\u6578\uff1a<\/p>\n<pre><code>SELECT * FROM NLS_SESSION_PARAMETERS;<\/code><\/pre>\n<p>\u78ba\u4fdd\u6240\u6709\u7684 NLS \u53c3\u6578\u503c\u90fd\u662f\u6709\u6548\u7684\uff0c\u4e26\u4e14\u7b26\u5408\u60a8\u7684\u61c9\u7528\u9700\u6c42\u3002<\/p>\n<h3 id=\"2-%e7%a2%ba%e8%aa%8d%e5%ad%97%e7%ac%a6%e9%9b%86-GYFQTnCsqP\">2. \u78ba\u8a8d\u5b57\u7b26\u96c6<\/h3>\n<p>\u6aa2\u67e5\u6578\u64da\u5eab\u548c\u61c9\u7528\u7a0b\u5e8f\u7684\u5b57\u7b26\u96c6\u8a2d\u7f6e\u662f\u5426\u4e00\u81f4\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u67e5\u8a62\u4f86\u67e5\u770b\u6578\u64da\u5eab\u7684\u5b57\u7b26\u96c6\uff1a<\/p>\n<pre><code>SELECT value FROM NLS_DATABASE_PARAMETERS WHERE parameter = 'NLS_CHARACTERSET';<\/code><\/pre>\n<p>\u5982\u679c\u5b57\u7b26\u96c6\u4e0d\u5339\u914d\uff0c\u60a8\u53ef\u80fd\u9700\u8981\u8abf\u6574\u61c9\u7528\u7a0b\u5e8f\u7684\u5b57\u7b26\u96c6\u8a2d\u7f6e\u3002<\/p>\n<h3 id=\"3-%e6%aa%a2%e6%9f%a5%e7%92%b0%e5%a2%83%e8%ae%8a%e9%87%8f-GYFQTnCsqP\">3. \u6aa2\u67e5\u74b0\u5883\u8b8a\u91cf<\/h3>\n<p>\u78ba\u4fdd\u64cd\u4f5c\u7cfb\u7d71\u7684\u74b0\u5883\u8b8a\u91cf\u8a2d\u7f6e\u6b63\u78ba\u3002\u7279\u5225\u662f <code>NLS_LANG<\/code> \u8b8a\u91cf\uff0c\u9019\u500b\u8b8a\u91cf\u61c9\u8a72\u8207\u6578\u64da\u5eab\u7684\u5b57\u7b26\u96c6\u76f8\u5339\u914d\u3002\u53ef\u4ee5\u4f7f\u7528\u4ee5\u4e0b\u547d\u4ee4\u4f86\u6aa2\u67e5\u74b0\u5883\u8b8a\u91cf\uff1a<\/p>\n<pre><code>echo $NLS_LANG<\/code><\/pre>\n<p>\u5982\u679c\u9700\u8981\uff0c\u60a8\u53ef\u4ee5\u901a\u904e\u4ee5\u4e0b\u547d\u4ee4\u4f86\u8a2d\u7f6e\u74b0\u5883\u8b8a\u91cf\uff1a<\/p>\n<pre><code>export NLS_LANG=AMERICAN_AMERICA.UTF8<\/code><\/pre>\n<h2 id=\"%e7%b5%90%e8%ab%96-GYFQTnCsqP\">\u7d50\u8ad6<\/h2>\n<p>\u5728 Oracle \u6578\u64da\u5eab\u4e2d\uff0c<code>ORA-12702<\/code> \u932f\u8aa4\u901a\u5e38\u662f\u7531\u65bc\u7121\u6548\u7684 NLS \u53c3\u6578\u5b57\u7b26\u4e32\u5f15\u8d77\u7684\u3002\u901a\u904e\u6aa2\u67e5 NLS \u53c3\u6578\u8a2d\u7f6e\u3001\u5b57\u7b26\u96c6\u548c\u74b0\u5883\u8b8a\u91cf\uff0c\u60a8\u53ef\u4ee5\u6709\u6548\u5730\u4fee\u5fa9\u6b64\u932f\u8aa4\u3002\u4e86\u89e3\u9019\u4e9b\u57fa\u672c\u6982\u5ff5\u4e0d\u50c5\u80fd\u5e6b\u52a9\u60a8\u89e3\u6c7a\u7576\u524d\u7684\u554f\u984c\uff0c\u9084\u80fd\u63d0\u9ad8\u60a8\u5728\u4f7f\u7528 Oracle \u6578\u64da\u5eab\u6642\u7684\u6574\u9ad4\u6548\u7387\u3002<\/p>\n<p>\u5982\u679c\u60a8\u5728\u5c0b\u627e\u9ad8\u6548\u7684 <a href=\"https:\/\/server.hk\">\u9999\u6e2fVPS<\/a> \u89e3\u6c7a\u65b9\u6848\uff0cServer.HK \u63d0\u4f9b\u591a\u7a2e\u9078\u64c7\uff0c\u6eff\u8db3\u60a8\u7684\u9700\u6c42\u3002\u7121\u8ad6\u662f\u6578\u64da\u5eab\u7ba1\u7406\u9084\u662f\u61c9\u7528\u7a0b\u5e8f\u958b\u767c\uff0c\u6211\u5011\u7684 <a href=\"https:\/\/server.hk\">\u4e91\u670d\u52d9\u5668<\/a> \u90fd\u80fd\u70ba\u60a8\u63d0\u4f9b\u7a69\u5b9a\u7684\u652f\u6301\u3002<\/p>\n","protected":false},"excerpt":{"rendered":"<p>\u89e3\u6c7a ORA-12702 \u932f\u8aa4\uff1a\u7121\u6548\u7684 NLS \u53c3\u6578\u5b57\u7b26\u4e32\uff0c\u63d0\u4f9b Oracle \u6545\u969c\u4fee\u5fa9\u548c\u9060\u7a0b\u8655\u7406\u6307\u5357\uff0c\u52a9\u60a8\u5feb\u901f\u6062\u5fa9\u7cfb\u7d71\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-84995","post","type-post","status-publish","format-standard","hentry","category-database"],"_links":{"self":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/84995","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=84995"}],"version-history":[{"count":1,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/84995\/revisions"}],"predecessor-version":[{"id":84996,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/posts\/84995\/revisions\/84996"}],"wp:attachment":[{"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/media?parent=84995"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/categories?post=84995"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/server.hk\/cnblog\/wp-json\/wp\/v2\/tags?post=84995"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}