如何在 Windows 中的 SQLPlus 中将 Oracle 编码更改为 AL32UTF8

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

How to Change Oracle Encoding to AL32UTF8 in SQLPlus in Windows

oracle

提问by Zetian

Iused the following command to test my Oracle current encoding

我使用以下命令来测试我的 Oracle 当前编码

select userenv('language') from dual;
select * from v$nls_parameters where parameter='NLS_CHARACTERSET';
select * from nls_database_parameters
select * from nls_instance_parameters
select * from nls_session_parameters

enter image description here

在此处输入图片说明

But what I want is AL32UTF8. How to change the encoding to AL32UTF8. Thanks~

但我想要的是 AL32UTF8。如何将编码更改为 AL32UTF8。谢谢~

采纳答案by dongx

Open your console

打开你的控制台

sqlplus "/ as sysdba"

SQL> shutdown immediate;
SQL> startup mount;
SQL> alter session set sql_trace=true;
SQL> alter system enable restricted session;
SQL> alter system set job_queue_processes=0;
SQL> alter system set aq_tm_processes=0;
SQL> alter database open;

//For version before oracle 9i like 8i, using these two lines
SQL> alter database character set internal_use UTF8;
SQL> alter database national character set internal_use UTF8;
//For version after oracle 9i, using these two lines
SQL> alter database character set internal_use AL32UTF8;
SQL> alter database national character set internal_use AL32UTF8;

SQL> alter session set sql_trace=false;
SQL> shutdown immediate;
SQL> startup;

回答by Wernfried Domscheit

There are two ways to set it.

有两种设置方法。

  • As Environment Variable NLS_LANG. Either temporarily with

    SET NLS_LANG=AMERICAN_AMERICA.AL32UTF8or in your Computer Property settings.

  • In your Registry at HKLM\SOFTWARE\ORACLE\KEY_%ORACLE_HOME_NAME%\NLS_LANG, resp. HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_%ORACLE_HOME_NAME%\NLS_LANGfor an 32-bit Oracle Client on Windows 64-bit.

  • 作为环境变量NLS_LANG。要么暂时与

    SET NLS_LANG=AMERICAN_AMERICA.AL32UTF8或在您的计算机属性设置中。

  • 在您的注册表中HKLM\SOFTWARE\ORACLE\KEY_%ORACLE_HOME_NAME%\NLS_LANG,分别为。HKLM\SOFTWARE\Wow6432Node\ORACLE\KEY_%ORACLE_HOME_NAME%\NLS_LANG对于 64 位 Windows 上的 32 位 Oracle 客户端。

In case you set both the Environment variable takes precedence.

如果您同时设置 Environment 变量优先。

Please note, when you set NLS_LANGvalue then you just tell the Oracle database "my client uses character set AL32UTF8" - it does not necessarily mean that your client is really using AL32UTF8!

请注意,当您设置NLS_LANGvalue 时,您只需告诉 Oracle 数据库“我的客户端使用字符集 AL32UTF8”——这并不一定意味着您的客户端确实在使用 AL32UTF8!

In case of SQL*Plus it inherits the character set from cmd.execodepage. You can interrogate and change it with command chcp, e.g.

在 SQL*Plus 的情况下,它从cmd.exe代码页继承字符集。您可以使用命令查询和更改它chcp,例如

C:\>chcp
Active code page: 850

C:\>chcp 65001
Active code page: 65001

C:\>sqlplus ...

See Code Page Identifiersto get a list of code pages.

请参阅代码页标识符以获取代码页列表。

However, according to your screenshot you use Java based SQL Developer. SQL Developer does not depend on NLS_LANGsetting. Check value in Tools -> Preferences -> Environment -> Encoding.

但是,根据您的屏幕截图,您使用的是基于 Java 的 SQL Developer。SQL Developer 不依赖于NLS_LANG设置。检查工具 -> 首选项 -> 环境 -> 编码中的值。