Oracle 10中修改字符集(character set)
Oracle 10.2.0.3資料庫原來的字符集是ZHS16GBK,為了支援更多的漢字,需要修改為ZHS32GB18030。
我首先想到原來在9i上修改字符集的方法,過程如下:
sys@CNHTM> shutdown immediate sys@CNHTM> alter system enable restricted session; |
暈啊,ZHS32GB18030字符集明明是ZHS16GBK的超集,查metalink才知道,原來在Oracle 10G中,修改字符集需要用csalter配合csscan完成。過程如下:
[@more@]安裝csscan
oracle@oracle[/home/oracle]> sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Wed Dec 23 19:58:21 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options sys@CNHTM> set termout on sys@CNHTM> set echo on sys@CNHTM> spool /tmp/csminst.log sys@CNHTM> @?/rdbms/admin/csminst.sql sys@CNHTM> rem sys@CNHTM> rem NAME sys@CNHTM> rem csminst.sql ... 省略n行 ... sys@CNHTM> rem ***************************************************************** sys@CNHTM> rem CSMV$EXTABLES lists all distinct objects to be scaned sys@CNHTM> rem ***************************************************************** sys@CNHTM> create or replace view csmig.csmv$extables 2 (obj#, usr#, property) 3 as 4 select distinct(obj#), usr#, property 5 from csm$extables where property=0; View created. sys@CNHTM> / View created. sys@CNHTM> commit 2 / Commit complete. sys@CNHTM> exit; Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options |
安裝後會自動退出plsql,可以檢查/tmp/csminst.log檔案,檢視安裝的詳細日誌。
測試csscan是否安裝成功
oracle@oracle[/home/oracle]> csscan table=sys.sql_version$ fromchar=zhs16gbk tochar=zhs32gb18030 log=instchkc capture=n process=1 array=1024000 Character Set Scanner v2.1 : Release 10.2.0.0.0 - Production on Wed Dec 23 20:15:30 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. Username: / as sysdba (這裡輸入使用者名稱密碼) Password: Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options Enumerating table to scan... . process 1 scanning SYS.SQL_VERSION$[AAAAIDAABAAAA/xAAA] Creating Database Scan Summary Report... Creating Individual Exception Report... Scanner terminated successfully. |
如果顯示Scanner terminated successfully.證明csscan安裝成功,會生成如下三個檔案。把這三個檔案刪除。
oracle@oracle[/home/oracle]> ls -l instchkc* -rw-r--r-- 1 oracle oinstall 1357 Dec 23 20:16 instchkc.err -rw-r--r-- 1 oracle oinstall 504 Dec 23 20:16 instchkc.out -rw-r--r-- 1 oracle oinstall 5481 Dec 23 20:16 instchkc.txt |
開始正式執行csscan,下一步的csalter過程依賴這一步的執行結果。
oracle@oracle[/home/oracle]> csscan full=y tochar=zhs32gb18030 array=1024000 process=2 Character Set Scanner v2.1 : Release 10.2.0.0.0 - Production on Wed Dec 23 20:21:14 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. Username: / as sysdba (這裡輸入使用者名稱密碼) Password: Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options Enumerating tables to scan... . process 1 scanning SYS.SOURCE$[AAAABIAABAAAAIRAAA] . process 2 scanning SYS.TYPE$[AAAAC1AABAAAAURAAA] ...省略n行... . process 2 scanning SYS.WRH$_INST_CACHE_TRANSFER[AAAMgoAADAAABNhAAA] . process 1 scanning SYSTEM.LOGMNRC_GTLO[AAABa0AADAAAAZhAAA] . process 2 scanning SYS.WRH$_DLM_MISC[AAAMhlAADAAAA5RAAA] Creating Database Scan Summary Report... Creating Individual Exception Report... Scanner terminated successfully. |
執行csalter,修改字符集
oracle@oracle[/home/oracle]> sqlplus / as sysdba SQL*Plus: Release 10.2.0.1.0 - Production on Wed Dec 23 20:34:12 2009 Copyright (c) 1982, 2005, Oracle. All rights reserved. Connected to: Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production With the Partitioning, OLAP and Data Mining options sys@CNHTM> @?/rdbms/admin/csalter.plb 4 rows created. Function created. Function created. Procedure created. This script will update the content of the Oracle Data Dictionary. Please ensure you have a full backup before initiating this procedure. Would you like to proceed (Y/N)?y old 6: if (UPPER('&conf') <> 'Y') then new 6: if (UPPER('y') <> 'Y') then Checking data validility... begin converting system objects PL/SQL procedure successfully completed. Alter the database character set... CSALTER operation completed, please restart database PL/SQL procedure successfully completed. 4 rows deleted. Function dropped. Function dropped. Procedure dropped. |
重啟資料庫
sys@CNHTM> shutdown immediate Database closed. Database dismounted. ORACLE instance shut down. sys@CNHTM> startup ORACLE instance started. Total System Global Area 167772160 bytes Fixed Size 1218292 bytes Variable Size 71305484 bytes Database Buffers 88080384 bytes Redo Buffers 7168000 bytes Database mounted. Database opened. |
檢查字符集
sys@CNHTM> select userenv('language') from dual; USERENV('LANGUAGE') ---------------------------------------------------- AMERICAN_AMERICA.ZHS32GB18030 |
結果顯示,修改成功
--end--
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/22049049/viewspace-1029939/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- 【轉】修改Oracle字符集(character set)Oracle
- rhel5_oracle10g_10.2.0.4_字符集character set_nls_valid_valueOracle
- mysql關於字符集character set的總結MySql
- rhel4 mysql5.5 字符集_character setMySql
- MYSQL5.5修改字符集報錯:unknown variable 'default-character-set=utf8'MySql
- MySQL字符集和校對規則(character set & collation)MySql
- Qt #pragma execution_character_set("utf-8") 執行字符集QT
- 修改oracle 10g的字符集Oracle 10g
- Oracle 字符集修改Oracle
- 修改oracle字符集Oracle
- oracle修改字符集Oracle
- oracle字符集修改Oracle
- oracle 修改字符集Oracle
- Oracle 10g修改字符集的方法:Oracle 10g
- oracle之修改字符集Oracle
- oracle9,10修改字符集--簡單方法Oracle
- Unknown initial character set index ‘255‘ received from server. Initial client character set can beIndexServerclient
- Oracle修改資料字符集Oracle
- 修改oracle client 的字符集Oracleclient
- 在rhel5上oracle10.2.0.4用sql指令碼生成儲存過程註解亂碼處理_character set_字符集OracleSQL指令碼儲存過程
- Indexing Mixed-Character Set ColumnsIndex
- character_set_database的意義Database
- 【Mysql】character-set-server引數MySqlServer
- 【nls_character】中文字元亂碼問題與字符集的修改字元
- 怎樣修改檢視Oracle字符集及怎樣修改字符集 ztOracle
- 修改Oracle資料庫字符集Oracle資料庫
- oracle 字符集檢視與修改Oracle
- 檢視和修改Oracle字符集Oracle
- Linux下修改Oracle字符集LinuxOracle
- 如何在10g中修改資料庫字符集資料庫
- MySQL環境變數裡關於字符集character_set相關引數的解釋MySql變數
- 檢視、修改oracle字符集,檢視oracle版本Oracle
- 修改Oracle資料庫字符集(zt)Oracle資料庫
- Oracle字符集的檢視和修改Oracle
- oracle 11g rac 修改字符集Oracle
- Oracle 字符集的檢視和修改Oracle
- mysql:Variable 'character_set_client' can't be set to the value of 'NULL'解決MySqlclientNull
- 關於MySQL中的8個 character_set 變數說明MySql變數