新电脑在安装是错误提示窗口报错信息为乱码。
Oracle服务端和plsql字符集不相同
更改客户端的字符集与服务器中的一致即可,这里统一修改为ZHS16GBK
// 注意:都同时改为utf8还是报错
原因:是数据库不支持中文,查询后发现中文的字符编码应该是SIMPLIFIED CHINESE_CHINA.ZHS16GBK
查看服务端编码:
SQL>select userenv(‘language’) from dual;
查询结果:
SIMPLIFIED CHINESE_CHINA.AL32UTF8
修改编码步骤
开始 - 运行 - 输入cmd 进入命令提示符(Windows系统)
输入 sqlplus /nolog
以管理员身份登录sqlplus
SQL> conn / as sysdba
Connected.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
System altered.
SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;
System altered.
SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;
System altered.
SQL> alter database open;
Database altered.
SQL> ALTER DATABASE CHARACTER SET ZHS16GBK;
ALTER DATABASE CHARACTER SET ZHS16GBK
ERROR at line 1:
ORA-12712: new character set must be a superset of old character set
提示我们的字符集:新字符集必须为旧字符集的超集,这时我们可以跳过超集的检查做更改:
SQL> ALTER DATABASE character set INTERNAL_USE ZHS16GBK;
Database altered.
SQL> select * from v$nls_parameters;
… …
19 rows selected.
重启检查是否更改完成:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 236000356 bytes
Fixed Size 451684 bytes
Variable Size 201326592 bytes
Database Buffers 33554432 bytes
Redo Buffers 667648 bytes
Database mounted.
Database opened.
SQL> select * from v$nls_parameters;
… …
19 rows selected.
更改完成后,重启下plsql,再在plsql中执行该SQL语句查看字符集是否更改为ZHS16GBK:
在plsql中执行 select userenv(‘language’) from dual;
发现已经是:SIMPLIFIED CHINESE_CHINA.ZHS16GBK
添加环境变量NLS_LANG
我的电脑-属性-高级系统设置-环境变量-设置NLS_LANG-保存退出
ok现在plsql和oracle服务端编码方式已经一致!乱码问题也解决了
补充:
关于Oracle字符集的有关知识可以参考这篇文章