Go to Oracle database it can store Chinese text sections or characters

Source: Internet
Author: User

A: Because the Oracle database it can store bytes or characters, for example char (a byte) char (A. Char), the meaning is different. In general, the default is to store bytes, and you can view the values of the database parameter nls_length_semantics.

1:sql> Show parameter nls_length_semantics;

2:

3:name TYPE VALUE

4:-------------------------------------------------

5:nls_length_semantics string BYTE

If defined as VARCHAR2, then the column can store up to 50 kanji, and if the definition field is VARCHAR2 (50) or VARCHAR2, then the maximum number of characters it can store will be determined by the database character set encoding.

Two: Oracle database Kanji occupies a few bytes, according to the Oracle character set encoding decision, in general, the database Nls_characterset is Al32utf8 or UTF8, that is, a Chinese character occupies three to four bytes. If Nls_characterset is ZHS16GBK, a character occupies two bytes.

1:sql> COL PARAMETER for A24;

2:sql> COL VALUE for A24 3:

Sql> SELECT * from v$nls_parameters WHERE parameter= ' Nls_characterset ';

4:

5:parameter VALUE

6:------------------------------------------------

7:nls_characterset UTF8

8:

9:sql> 10:

As for the specific situation, you can use the LENGTHB or Vsize function to calculate the number of bytes occupied.

1:sql> SELECT LENGTH (' Hello ') from DUAL;

2:

3:length (' Hello ')

4:--------------

5:2

6:

7:

sql> SELECT lengthb (' Hello ') from DUAL;

8:

9:LENGTHB (' Hello ')

Ten:---------------

11:6

12:

The length function evaluates to a number of characters, and the LENGTHB or Vsize function evaluates to the number of bytes consumed.

Vsize returns the number of bytes in the internal representation of expr. IF expr is null and then this function returns NULL. This function does not the support CLOB data directly. However, CLOBs can be passed in as arguments through implicit data conversion.

Length is the number of characters to be calculated, and the input parameters are first converted to character type calculation

The length functions return the length of char. Length calculates length using characters as defined by the input characte R set. LENGTHB uses bytes instead of characters. LENGTHC uses Unicode complete characters. LENGTH2 uses UCS2 code points. LENGTH4 uses UCS4 code points.

Xiaoxiang Hidden Person

Source: http://www.cnblogs.com/kerrycode/

Solutions

1.

Sql> Select Userenv (' language ') from dual;

USERENV (' LANGUAGE ') American_america. Al32utf8

3. Modify the Linux Nls_lang environment variable and modify the ". Base_profile" file under Oracle's specified Linux user, by adding the following: Export nls_lang= "American_america. Al32utf8 "

4. Execute. Bash_profile, make the environment variable settings effective, and view its value: $ echo $NLS _lang Merican_america. Al32utf8

At this point, the Chinese garbled problem has been resolved.

Go to Oracle database it can store Chinese text sections or characters

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.