Oracle 字符编码

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/6015217/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-18 23:40:50  来源:igfitidea点击:

Oracle character encoding

oraclecharacter-encodingspecial-charactersoracle11g

提问by mcha

I have an MVIEW on the DEV server as

我在 DEV 服务器上有一个 MVIEW 作为

CREATE MATERIALIZED VIEW MY_MVIEW
AS
SELECT  col1 AS "N° INVOICE" from TABLE

The MVIEW has been installed on PROD server and when i check for its query i have the characther °not recognized

MVIEW 已安装在 PROD 服务器上,当我检查其查询时,我°无法识别该字符

SELECT query from user_mviews where mview_name = 'MY_MVIEW' ;

QUERY
---------------------------------------
SELECT  col1 AS "N? INVOICE" from TABLE

we use Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Productionfor both environments .

我们Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production用于两种环境。

Any idea why this happened and how to correct it? or I need to rename my alias?

知道为什么会发生这种情况以及如何纠正吗?或者我需要重命名我的别名?

回答by HAL 9000

Whenever you see a question mark instead of a special character it means that the client's character set does not support that character and a conversion was not available.

每当您看到问号而不是特殊字符时,就意味着客户端的字符集不支持该字符并且无法进行转换。

The conversion happens with the database character set as the source and the client character set as the target. The environment variable NLS_LANGlets you control the client character set. NLS_LANG must be set before the connection is opened and it cannot be changed during the session.

转换以数据库字符集为源,客户端字符集为目标。环境变量NLS_LANG可让您控制客户端字符集。NLS_LANG 必须在打开连接之前设置,并且在会话期间不能更改。

For more information about NLS_LANG refer to the Oracle? Database Globalization Support Guide

有关 NLS_LANG 的更多信息,请参阅Oracle? 数据库全球化支持指南

BTW, NLS_LANGUAGE has nothing to do with the character set! It only controls language used in server messages and locale settings.

顺便说一句,NLS_LANGUAGE 与字符集无关!它仅控制服务器消息和区域设置中使用的语言。

回答by Tony Andrews

I would definitely recommend renaming your alias to something simple like NO_INVOICE that doesn't contain any unusual characters and doesn't need embedding in double quotes to reference. It is not appropriate to treat column names as if they are formatted headings for reports - do that in the report. With non-standard characters like this you are going to get problems with different environmental settings like NLS_LANG.

我绝对建议您将别名重命名为简单的名称,例如 NO_INVOICE,它不包含任何异常字符并且不需要嵌入双引号来引用。将列名称视为报告的格式化标题是不合适的 - 在报告中这样做。对于像这样的非标准字符,您将遇到不同环境设置(如 NLS_LANG)的问题。