天天看點

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. 徹底打開資料