首页 > 代码库 > 修改oracle字符集

修改oracle字符集

最近在做项目中 遇到了oracle数据库中查出来汉字全是乱码,因为字符集不一致,所以要修改自己oracle的字符集,具体步骤如下:

通过ORACLE的SQL PLUS命令窗口改

在SQL*PLUS 中,以DBA登录

conn 用户名 as sysdba

然后执行以下命令

 

>shutdown immediate; (把database停了)

>startup mount; (把database重开去可更改情況)

>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 utf8;

执行上面这行可能会报错:
ALTER DATABASE CHARACTER SET ZHS16GBK  ERROR at line 1:
    
 ORA-12712: new character set must be a superset of old character set
解决办法:
>ALTER DATABASE character set INTERNAL_USE utf8;

>shutdown immediate;

>startup; (重开正常oracle)

最后在注册表找到:
 HKEY_LOCAL_MACHINE -> SOFTWARE ->Oracle->KEY_XE-> 右边窗体点击 NLS_LANG -> 将目标字符集写在里面即可 "AMERICAN_AMERICA.UTF8" ->OK ->CLOSE REGISTRY
重启监听和服务

修改oracle字符集