Oracle Chinese Character occupies byte length, oracle Chinese Character byte
1. When investigating an oracle database problem today, we found that one Chinese Character occupies 2 bytes in 11G and 3 in 10g, as a result, the data in the 11g Database is always wrong when it is imported into the 10g Database. At the beginning, it was thought that the version of the 11g Database is different from that of the 10g Database, and the number of Chinese characters is different. Later I thought, oracle won't do this, so the difference is too big. Later, a survey found that it is related to oracle character set encoding:
For the following character sets, one Chinese Character occupies 2 bytes: SIMPLIFIED CHINESE_CHINA.ZHS16GBK for the following character sets, one Chinese Character occupies 3 bytes: SIMPLIFIED CHINESE_CHINA.AL32UTF8 (1) you can view the oracle character set in the following SQL: select userenv ('language') from dual (2) to view the number of bytes of a Chinese character in the current oracle environment, use the following SQL statement: select lengthb ('Ah ') from dual knowledge about oracle character sets, including Character Set viewing and modification, with reference to: http://www.cnblogs.com/rootq/articles/2049324.html http://blog.csdn.net/uestcong/article/details/7348008
How many bytes of oracle Chinese Characters
Previously, I thought that a Chinese character occupies two bytes. This is true for MSSQL Server (at least within the scope of my understanding. If there is an error, please correct it ). But recently I have been using the Oracle database and found some special things, that is, when you use two functions (length and lengthb respectively, what are these two functions used, I don't want to explain it. You can check it for help.) During the query, the result is that lengthb is three times the length (the premise is that the parameters in the length function are all Chinese characters ), this is strange. Isn't Chinese characters occupying two bytes? Why is it three here? So I found the information online. This is actually related to Oracle configuration. Use the following statement to query: select * from v $ nls_parameters t where t. PARAMETER = 'nls _ CHARACTERSET '; the character set of the current database can be queried. If value = ZHS16GBK, one Chinese Character occupies 2 bytes. If value = AL32UTF8, therefore, a Chinese character occupies three bytes. After querying my database, the character set is AL32UTF8 (which is the default Character Set of the Oracle database ).
How many bytes of a character in ORACLE?
22.1 question Description: Maybe you can say that a Chinese character occupies 2 bytes. Is this certain? How to calculate the number of bytes of a string? 22.2 The solution occupies several bytes in oracle, especially Chinese characters. For example, if I create a table create table test_ly (a varchar2 (4), B nvarchar2 (4), can you insert two Chinese characters into column? Error! You can insert at most one Chinese character with one letter (or number ). Why? Because a Chinese character occupies three bytes in field a, and other characters (such as numbers, letters, or punctuation marks) occupy one byte, how many Chinese characters can be inserted at most in column B? Error! Column B can contain up to four Chinese characters. A Chinese character or other characters (such as numbers, letters, or punctuation marks) in column B are two bytes. It can be seen that in the Field Types starting with N (such as NCHAR and NVARCHAR2), any one character (including one Chinese character) occupies 2 bytes and is unified. In fields not starting with N (such as CHAR and VARCHAR2), unicode characters (such as Chinese characters) occupy three bytes, while other characters occupy one byte. How to calculate the number of characters and the number of characters occupied by a string? The Length function obtains the number of characters in use, and the lengthb or vsize function obtains the number of bytes in use. How many characters and bytes are occupied by the Chinese character string 12? The SQL return value is clear. Select length ('zhonghua 12') from dual -- returns 4, that is, occupies 4 characters select lengthb ('zhonghua 12') from dual -- returns 8, that is to say, it occupies 8 bytes, and the Chinese son occupies 3 bytes, while the 12 character occupies 1 byte respectively. select lengthb (N 'chinam1') from dual -- 6 is returned, this is to convert the string into a unicode string, each character occupies 2 bytes, 3 is 6 bytes select length (N 'zhonghua 1') from dual -- return 3, because it only contains three characters. The default length of a string field is BYTE, depending on the value of the nls_length_semantics parameter. The default value is BYTE, it is measured in bytes. If it is CHAR, it is measured in characters. Can a column in a table use characters? Of course, you can create it like this: create table test_ly (a varchar2 (4 char) so that column a can store up to four characters instead of four bytes.