oracle 仅为 SQL*Plus 设置 NLS_LANG

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

setting NLS_LANG only for SQL*Plus

oraclesqlplus

提问by haki

I have NLS_LANGset in the registry for my local language. The CMD is not able to display the characters of my local language so i see jibrish. i'm talking about prompts from the client and not actual data, error messages for example.

NLS_LANG在注册表中设置了我的本地语言。CMD 无法显示我当地语言的字符,所以我看到了 jibrish。我说的是来自客户端的提示而不是实际数据,例如错误消息。

SQL> conn scott/tiger
ετσ?°.

I need to keep the client's setting to the local NLS because other programs are dependent on it.

我需要将客户端的设置保留在本地 NLS 中,因为其他程序依赖于它。

I've tried adding $set NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252in the glogin but obviously it's not working since the script is executed only after sql*Plus had already been started.

我已经尝试添加$set NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252glogin,但显然它不起作用,因为脚本仅在 sql*Plus 已经启动后执行。

My question is , is there any way of setting the NLS_LANGto AMERICAN_AMERICA.WE8MSWIN1252onlyfor SQL*Plus ?

我的问题是,有没有什么方法NLS_LANG可以AMERICAN_AMERICA.WE8MSWIN1252为 SQL*Plus设置to ?

回答by Ludovic Feltz

NLS_LANGcannot be changed for the session in SQL*Plus. You can only set the langage, territory, numeric characters, etc ... For example:

NLS_LANG不能为 SQL*Plus 中的会话更改。您只能设置语言、地域、数字字符等...例如:

ALTER SESSION SET NLS_LANGUAGE = 'AMERICAN';
ALTER SESSION SET NLS_NUMERIC_CHARACTERS = '.,';

NLS_LANGis set as an environment variable, so before running SqlPlususe:

NLS_LANG被设置为环境变量,所以在运行SqlPlus之前使用:

On Windows:

在 Windows 上:

set NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252

On Unix (Solaris and Linux, centos etc)

在 Unix(Solaris 和 Linux、centos 等)上

export NLS_LANG=AMERICAN_AMERICA.WE8MSWIN1252

回答by David Aldridge

You can use the login.sql or glogin.sqlto run arbitrary commands when SQL*Plus starts, so set the appropriate session settings in there

您可以使用login.sql 或 glogin.sql在 SQL*Plus 启动时运行任意命令,因此请在其中设置适当的会话设置

回答by Stuart Smith

This worked for me when I ran into the same issue today

当我今天遇到同样的问题时,这对我有用

From a windows command prompt run before running sqlplus

在运行 sqlplus 之前从 Windows 命令提示符运行

set NLS_LANG=.AL32UTF8

回答by ErolCimen

alter session set nls_language='AMERICAN';

更改会话集 nls_language='AMERICAN';

will solve your problem...

会解决你的问题...

回答by Saddam ZEMMALI

set linesize 2000;
select * from NLS_DATABASE_PARAMETERS; 


SHUTDOWN IMMEDIATE;

STARTUP MOUNT;

ALTER SYSTEM ENABLE RESTRICTED SESSION;

ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;

ALTER SYSTEM SET AQ_TM_PROCESSES=0;

ALTER DATABASE OPEN;

ALTER DATABASE CHARACTER SET INTERNAL_USE  WE8MSWIN1252;
alter database national character set internal_use AL16UTF16;

SHUTDOWN IMMEDIATE; 
STARTUP;