工作需要,安裝裝了oracle 11g,在匯入其他機器上的備份資料的時間,發生一個錯誤:
IMP-00019: 由於 ORACLE 錯誤 12899 而拒絕行
IMP-00003: 遇到 ORACLE 錯誤 12899
ORA-12899: 列 "ZHENG"."D_DIC"."DICEXPLAIN" 的值太大 (實際值: 140, 最大值: 100)
這個資料表結構是直接注入的,根本不會這樣子的啊。後來在網上查了才知道原來是字元集的問題:
在記錄檔裡,開始匯入時候有這樣一個提示:"
已經完成 ZHS16GBK 字元集和 AL16UTF16 NCHAR 字元集中的匯入
匯入伺服器使用 AL32UTF8 字元集 (可能的字元集轉換)
"原來在我的Windows server 2003系統上安裝oracle,預設的字元集跟作業系統一致,是AL32UTF8。
AL32UTF8裡,一個漢字是佔用3個字元位,而一般我們用Windows XP中預設的是ZHS16GBK ,一個漢字用2個字元位。這樣,直接匯入資料就直接溢出了。
查看資料庫的字元集
select * from v$nls_parameters;
select * from nls_database_parameters;
oracle資料庫的字元集更改
[root@server183 /]# sqlplus /nolog
SQL*Plus: Release 11.2.0.1.0 Production on Wed Nov 7 23:50:56 2012
Copyright (c) 1982, 2010, Oracle. All rights reserved.
SQL> conn / as sysdba --需要使用SYSDBA帳戶
Connected.
SQL> startup mount
ORA-01081: cannot start already-running ORACLE - shut it down first
SQL> shutdown immediate; --停止資料庫
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount --啟動資料庫到 mount 狀態
ORACLE instance started.
Total System Global Area 1686925312 bytes
Fixed Size 2176368 bytes
Variable Size 989858448 bytes
Database Buffers 687865856 bytes
Redo Buffers 7024640 bytes
Database mounted.
SQL> alter session set sql_trace=true;
Session altered.
SQL> alter system enable restricted session;
System altered.
SQL> alter system set job_queue_processes=0;
System altered.
SQL> alter system set aq_tm_processes=0;
System altered.
SQL> alter database open;
Database altered.
SQL> ALTER DATABASE character set INTERNAL_USE ZHS16GBK; --修改字元集AL32UTF8->ZHS16GBK
Database altered.
SQL> shutdown immediate; --再次關閉資料庫
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP --啟動資料庫
ORACLE instance started.
Total System Global Area 1686925312 bytes
Fixed Size 2176368 bytes
Variable Size 989858448 bytes
Database Buffers 687865856 bytes
Redo Buffers 7024640 bytes
Database mounted.
Database opened.
SQL> select * from v$nls_parameters where parameter = 'NLS_CHARACTERSET';
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
client端字元集修改
在 /home/oracle與 /root使用者目錄下的.bash_profile中
添加或修改 export NLS_LANG="AMERICAN_AMERICA.UTF8" 語句
關閉當前ssh視窗。