Oracle里汉字长度问题!

类别:数据库 点击:0 评论:0 推荐:
以前在做一个系统时,遇到了一个问题!今天无意之中找到了这个问题的解决方法,贴出来!!!

问题描述:
                varchar2(4000) abc;
                intert into table_name(abc) values('这里有1500个汉字……');
                报错:插入字符过长!经过测试,发现一个汉字占3个字节,所以报错!!!

问题所在:
                使用的字符集是UTF8,就有可能出现这个错误!
                使用命令查看:
                SQL> select * from v$nls_parameters where parameter='NLS_CHARACTERSET';

                PARAMETER
                --------------------------------------------------------------------------------
                VALUE
                --------------------------------------------------------------------------------
                NLS_CHARACTERSET
                AL32UTF8

解决方法:
                建议使用ZHS16GBK字符集!
                操作:
                        SQL> SHUTDOWN IMMEDIATE; 
                        SQL> STARTUP MOUNT; 
                        SQL> ALTER SYSTEM ENABLE RESTRICTED SESSION; 
                        SQL> ALTER SYSTEM SET JOB_QUEUE_PROCESSES=0; 
                        SQL> ALTER DATABASE OPEN; 
                        SQL> ALTER DATABASE CHARACTER SET AL32UTF8/ZHS16GBK;
                        SQL> SHUTDOWN IMMEDIATE;
                        SQL> STARTUP;
                
问题解决!!!

本文地址:http://com.8s8s.com/it/it19640.htm