如何修改Oracle資料庫字元集

來源:互聯網
上載者:User

環境:
OS:Red Hat Linux As 5
DB:Oracle 10.2.0.4
 
通常情況下,字元集是在安裝的時候選定好的,需要修改資料庫的字元集Oracle建議的做法是重建資料庫(EXP/EXPDP匯出後再匯入),雖然Oracle官方文檔也有說如何修改字元集,但這不是Orale推薦的方法.下面是Oracle官方文檔中提到的如何修改字元集的方法.
 
1.查看當前資料庫字元集
select * from nls_database_parameters
where parameter='NLS_CHARACTERSET';
-----------------------------------
PARAMETER         VALUE
NLS_CHARACTERSET WE8ISO8859P1
 
這裡的字元集WE8ISO8859P1是不支援中文的
 
2.將字元集修改為中文字元集ZHS16GBK
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP MOUNT;
ORACLE instance started.
Total System Global Area  734003200 bytes
Fixed Size                  1221564 bytes
Variable Size             264244292 bytes
Database Buffers          465567744 bytes
Redo Buffers                2969600 bytes
Database mounted.
SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION;
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> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area  734003200 bytes
Fixed Size                  1221564 bytes
Variable Size             264244292 bytes
Database Buffers          465567744 bytes
Redo Buffers                2969600 bytes
Database mounted.
Database opened.
 
這樣將資料庫的字元集由原來的WE8ISO8859P1修改成了ZHS16GBK,對原來的字元集有中文的顯示的還是亂碼,但對新入庫的中文字元集就能正常顯示.
 
-- The End --

聯繫我們

該頁面正文內容均來源於網絡整理,並不代表阿里雲官方的觀點,該頁面所提到的產品和服務也與阿里云無關,如果該頁面內容對您造成了困擾,歡迎寫郵件給我們,收到郵件我們將在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.