調整oracle資料庫編碼

來源:互聯網
上載者:User

標籤:oracle資料庫編碼

新裝資料庫可能需要調整oracle資料庫編碼,否則在匯入資料是可能會出錯。


oracle11g更改字元集AL32UTF8為ZHS16GBK

 

Sql代碼  

Database character set (AL32UTF8) and Client character set (ZHS16GBK) are different.   

Character set conversion may cause unexpected results.   

Note: you can set the client character set through the NLS_LANG environment variable or the NLS_LANG registry key in   

HKEY_LOCAL_MACHINE\SOFTWARE\ORACLE\KEY_OraDb11g_home1.   

  

SIMPLIFIED CHINESE_CHINA.ZHS16GBK 包含 AMERICAN_AMERICA.AL32UTF8.   

-- 這可是個麻煩事,不是改用戶端字元集的問題。要改資料庫的字元集。  


SQL>select userenv(‘language‘) from dual; //查看本機字元集


SQL> conn /as sysdba   

SQL> shutdown immediate;   

SQL> startup mount   

SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;   

SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0;   

SQL> ALTER SYSTEM SET AQ_TM_PROCESSES=0;   

SQL> alter database open;   

SQL> ALTER DATABASE CHARACTER SET ZHS16GBK;   

ORA-12712: new character set must be a superset of old character set   

--提示我們的字元集:新字元集必須為舊字元集的超集,這時我們可以跳過超集的檢查做更改:   

SQL> ALTER DATABASE character set INTERNAL_USE ZHS16GBK;   

--我們看到這個過程和之前ALTER DATABASE CHARACTER SET操作的內部過程是完全相同的,也就是說INTERNAL_USE提供的協助就是使Oracle資料庫繞過了子集與超集的校正.   

SQL> select * from v$nls_parameters;    

SQL> shutdown immediate;   

SQL> startup   

SQL> select * from v$nls_parameters;   

--以後安裝oracle11g的時候記得選擇自訂安裝,把這個字元集的事情事先弄好。  


資料庫查詢亂碼:


[email protected]:~>cat .profile

export NLS_LANG=‘AMERICAN_AMERICA.ZHS16GBK‘


#SLES預設安裝時:添加

vim /etc/profile.d/oracle.sh

export NLS_LANG=‘AMERICAN_AMERICA.ZHS16GBK‘


本文出自 “韓磊” 部落格,請務必保留此出處http://deararvin.blog.51cto.com/11158301/1739636

調整oracle資料庫編碼

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在5個工作日內處理。

如果您發現本社區中有涉嫌抄襲的內容,歡迎發送郵件至: info-contact@alibabacloud.com 進行舉報並提供相關證據,工作人員會在 5 個工作天內聯絡您,一經查實,本站將立刻刪除涉嫌侵權內容。

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.