天天看点

oracle 中文乱码问题

oracle虽然在.bash_profile中设置了NLS_LANG="SIMPLIFIED CHINESE_CHINA".ZHS16GBK;export NLS_LANG,但是在查询带有中文字符的表时,仍然乱码的问题。

在生产环境中:

  1. 全备份数据库。
  2. 查看当前字符集:

    select * from  nls_database_parameters where  parameter='NLS_CHARACTERSET';

    查询到结果是RedHat操作系统自己默认的字符集:WE8ISO8859P1

  3. 关闭数据库

    shutdown  immediate;

  4. 启动数据库到挂载阶段;mount

    startup  mount;

  5. 限制连接会话

    alter  system  enable  restricted  session;

  6. 查看工作进程队列;

    show  parameter  job_queue_processes;

    show  parameter  aq_tm_processes;

  7. 更改工作队列数为0个;

    alter  system  set  job_queue_processes=0;

  8. 打开数据库;

    alter  system  set  character=ZHS16GBK;

    执行完上个命令,如果报ORA-12712,这个错误,则表示要更改的新字符集必须是老字符集的超集;

    于是更改语句,执行下面的语句;

    alter  database character  set internal_use ZHS15GBK;

  9. 查询当前数据库的字符集是否更改成功。
  10. 成功后,关闭数据库;
  11. 打开数据库到mount阶段;
  12. 更改工作队列进程数据,为第六步查询的结果;

    alter  system  set  job_queue_processes=10;

  13. 彻底打开数据