oracle(通过 sql/plus)如何确定用于评估 sql 脚本的字符集

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/20956703/
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-19 02:09:57  来源:igfitidea点击:

How does oracle (via sql/plus) determine the charset used to evaluate a sql script

sqloracle

提问by scherzoteller

I'd like to have a few details about how oracle (via sql/plus) determine the charset used to evaluate a sql script.

我想了解一些有关 oracle(通过 sql/plus)如何确定用于评估 sql 脚本的字符集的详细信息。

My database is configured like this:

我的数据库是这样配置的:

select VALUE from nls_database_parameters where parameter='NLS_CHARACTERSET';
VALUE
------
WE8ISO8859P15

The problem is that I read here http://www.orafaq.com/wiki/NLSthat session parameters could take precedence over database parameters.

问题是我在这里读到http://www.orafaq.com/wiki/NLS会话参数可以优先于数据库参数。

Does it mean that database encoding is overriden by the one defined in the NLS_LANG environment variable of the user who executes the script?

这是否意味着数据库编码被执行脚本的用户的 NLS_LANG 环境变量中定义的编码覆盖?

Apparently, it's not possible to modify the encoding in a script via an alter session statement.

显然,不可能通过更改会话语句修改脚本中的编码。

I'm asking this question since I already had a problem of corrupted characters with a production script executed by a subcontractor in India. I actually don't know if it was because he did something wrong with my file (like copy/paste in a sql gui client) or if it was because of his environment.

我问这个问题是因为我已经遇到了一个由印度分包商执行的生产脚本的字符损坏问题。我实际上不知道是因为他对我的文件做错了什么(比如在 sql gui 客户端中复制/粘贴)还是因为他的环境。

To summarize my actual problem, will everything be OK if

总结我的实际问题,如果一切正常

  • The user is configured with a charset of UTF8

  • My sql file is encoded in UTF8

  • My database is in WE8ISO8859P15

  • 用户配置了 UTF8 字符集

  • 我的 sql 文件是用 UTF8 编码的

  • 我的数据库在 WE8ISO8859P15

Thank's in advance for your answers.

提前感谢您的回答。

采纳答案by HAL 9000

Yes, you are correct. The Oracle Client always converts between the database characterset and the characterset of the client machine, which is determined by the NLS_LANG environment variable or the system settings.

是的,你是对的。Oracle 客户端总是在数据库字符集和客户端机器的字符集之间进行转换,这由 NLS_LANG 环境变量或系统设置决定。

Please note that UTF8 supports only Unicode version 3.1 and earlier. Use AL32UTF8 instead to get full Unicode support.

请注意,UTF8 仅支持 Unicode 3.1 及更早版本。改用 AL32UTF8 以获得完整的 Unicode 支持。