刚刚上班,师父叫在centos上装个oracle11gr2,搞了三四天,总算装好了,却遗留一个sqlplus乱码的问题。初步原定定位在选择字符集的时候,我当时选的是UTF8。

我把数据库删除了,重新建立,到那一步选择了系统默认,结果还是出现乱码。

我再来一次 直接选择了ZHS16GBK,结果还是一样。

其实一直搞错了,刚开始我选择了utf-8,由于Centos默认应该是GBK,所以显示的问号。

现在只需要一个方法

编辑并运行.bash_profile

从oracle官方文档了解到NLS_LANG变量的功能是

Specifies the language, territory, and character set of the client

environment. The client character set specified by NLS_LANG must match

the character set of the terminal or terminal emulator. If required, NLS_

LANG can be temporarily reset to another character set before starting a

non-interactive batch program to match the character set of files and

scripts processed by this program. The character set specified by NLS_LANG

can be different from the database character set, in which case the

character set is automatically converted.export

根据创建数据库时选择的字符集修改NLS_LANG变量

如果是UTF-8:exiport NLS_LANG=AMERICAN_AMERICA.UTF8

如果是 GBK: export NLS_LANG=american_america.ZHS16GBK)

注销后生效

这样再重新进入sqlplus

已经不会是乱码。