1. When data is inserted into the database table a few days ago, the following error is reported: SQLgt; insertintostudentvalues (
1. When data is inserted into the database table a few days ago, the following error is reported: SQLgt; insert into student values (
1. the following error is reported when data is inserted into the database table a few days ago:
SQL> insert into student values ('People 'S REPUBLIC OF CHINA ', 60 );
Insert into student values ('People 'S republic of china ', 60)
*
Row 3 has an error:
ORA-12899: the value of column "SYSTEM". "STUDENT". "NAME" is too large (actual value: 12, maximum value: 6)
The character length is set to 6 when a table is created, but an error is reported when six Chinese characters are inserted. The table structure is as follows:
SQL> desc student;
Is the name empty? Type
-----------------------------------------------------------------------------
NAME VARCHAR2 (6)
Age number (3)
After checking a large amount of data, we found that the varchar2 length is determined by the character set type.
The content is as follows:
Varchar2 is up to 4000 bytes, So it depends on your Oracle character set. If the character set is 16-bit encoded, ZHS16GBK, that
Each character is 16 characters and 2 bytes. It can contain one Chinese character, so it can contain 2000 characters. If it is an AL32UTF8 character set, the three bytes are a Chinese character, then only 1333 characters can be stored.
2. view the statements of the character set type:
SQL> set wrap off;
SQL> select parameter, value from nls_database_parameters where parameter like 'nls _ CHARACTERSET ';
PARAMETER VALUE
-------------------------------------------------------------------------------
NLS_CHARACTERSET ZHS16GBK
Therefore, the characters inserted above can only be 3 Chinese characters.
If you change the character encoding above to 32-bit encoding, you can only store 1.5 Chinese characters.
3.10 view Character Set settings of the new database
SQL> set wrap off
SQL> set lines 1000
SQL> select * from nls_database_parameters;
4. You can use update props $ set value $ = 'zhs16gbk' where;
To modify character sets
5. If the character set is AL32UTF8, the following example shows that each Chinese Character occupies three bytes.
SQL> select lengthb ('中') from dual;
LENGTHB ('zhong ')
-------------
3