系统ORACLE数据库迁移后出现列值过大的问题(原库没问题)
经分析是由于数据库字符集不一样的问题导致:
解决方案:
oracle修改“NLS_NCHAR_CHARACTERSET”字符集
测试数据库的NLS_NCHAR_CHARACTERSET和正式环境不一致,需要由UTF8修改为AL16UTF16。
1、停数据库
SQL> alter system checkpoint;
System altered.
SQL> alter system checkpoint;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
2、启动数据库
SQL> STARTUP MOUNT EXCLUSIVE;
ORACLE instance started.
Total System Global Area 838860800 bytes
Fixed Size 2024536 bytes
Variable Size 192940968 bytes
Database Buffers 637534208 bytes
Redo Buffers 6361088 bytes
Database mounted.
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 NATIONAL CHARACTER SET INTERNAL_USE AL16UTF16;
Database altered.
注意:
1)这样修改会影响数据库中定义了Nclob、NVARCHAR2等大字段的表,会出现乱码。需要重新导入表,当然在修改前要备份相关表。
2)如果没有大对象,在使用过程中进行语言转换没有什么影响,(切记设定的字符集必须是ORACLE支持,不然不能start)
若直接运行
ALTER DATABASE NATIONAL CHARACTER SET AL16UTF16;
也可以,但是可能会出现‘ORA-12717: Cannot ALTER DATABASE NATIONAL CHARACTER SET when
NCLOB data exists’ 这样的提示信息