Oracle 中的 NLS_LANG 参数

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

NLS_LANG parameter in Oracle

sqloracle

提问by user2837961

I have installed oracle with chracterset POLISH_POLAND.EE8MSWIN1250. I can checked the values in select * from nls_database_parameters which are NLS_CHARACTERSET=EE8MSWIN1250 and NLS_NCHAR_CHARACTERSET=AL16UTF16

我已经安装了带有字符集 POLISH_POLAND.EE8MSWIN1250 的 oracle。我可以检查 select * from nls_database_parameters 中的值,即 NLS_CHARACTERSET=EE8MSWIN1250 和 NLS_NCHAR_CHARACTERSET=AL16UTF16

For sqlplus, I have set NLS_LANG to POLISH_POLAND.EE8PC852. Now I run a sql file from sqlplus command prompt which is saved in "UTF-8 without BOM" as it has polish characters and it works fine. But how do I check if the values are fine in the database?

对于 sqlplus,我已将 NLS_LANG 设置为 POLISH_POLAND.EE8PC852。现在我从 sqlplus 命令提示符运行一个 sql 文件,该文件保存在“没有 BOM 的 UTF-8”中,因为它有波兰语字符并且工作正常。但是如何检查数据库中的值是否正常?

I have checked in SQL Developer (after setting the NLS_LANG to polish) and they do not look correct. Please help.

我已经检查了 SQL Developer(在将 NLS_LANG 设置为波兰语之后)并且它们看起来不正确。请帮忙。

回答by Codo

The character set of your Oracle installation is mainly relevant for defining what characters you store. If your client uses a different encoding, Oracle will automatically convert it. If I'm not mistaken, it will even warn you if you try to save a character that's not part of your encoding.

您的 Oracle 安装的字符集主要与定义您存储的字符相关。如果您的客户端使用不同的编码,Oracle 将自动转换它。如果我没记错的话,它甚至会在您尝试保存不属于您的编码的字符时警告您。

In your case, the main challenge is how to tell SQLplus the encoding of your text file (SQL file). As it is UTF-8, you need to specify a UTF-8 value:

在您的情况下,主要挑战是如何告诉 SQLplus 您的文本文件(SQL 文件)的编码。由于它是 UTF-8,您需要指定一个 UTF-8 值:

set NLS_LANG=.AL32UTF8

Or:

或者:

set NLS_LANG=POLISH_POLAND.UTF8

That should do the trick.

这应该够了吧。

Note that SQLplus does not support UTF-8 with BOM. But this doesn't seem to be relevant for you at the moment.

请注意,SQLplus 不支持带有 BOM 的 UTF-8。但这目前似乎与您无关。

回答by Wernfried Domscheit

NLS_CHARACTERSET just defines how text is binary saved inside Oracle database - and thus also defines characters which are possible to store in DB.

NLS_CHARACTERSET 只是定义了文本在 Oracle 数据库中的二进制保存方式——因此也定义了可以存储在 DB 中的字符。

In case your SQL file is UTF-8 it is certainly different to an PC852 or 1250 file. Change your local NLS_LANG to POLISH_POLAND.AL32UTF8then it should work.

如果您的 SQL 文件是 UTF-8,它肯定与 PC852 或 1250 文件不同。将您的本地 NLS_LANG 更改为POLISH_POLAND.AL32UTF8它应该可以工作。