Summary of Oracle Character set issues

Source: Internet
Author: User

In the process of Web development and Oracle installation, people often do not understand the character set, so summarize this.

1. First question: What is the difference between character sets?

Common character sets are: UTF-8 and GBK

(1) GBK Character Set

    • GBK text encoding is a double-byte representation, that is, both Chinese and English characters are represented by double-byte, but in order to distinguish English, the highest bit is set to 1.
    • GBK contains all Chinese characters;
    • GBK is in the national standard GB2312 based on the expansion of compatible GB2312 standards (as if not national standards)
    • GBK is the country code, the generality is worse than the UTF8, but the UTF8 occupies the database than GBK big ~

(2) UTF-8 Character Set

    • UTF-8 encoding is a multi-byte encoding used to solve international characters, which uses 8 bits (or one byte) in English and is encoded in Chinese using 24 bits (three bytes). For forums with more English characters, you can save space with UTF-8.
    • UTF-8 contains the characters that are needed for all countries in the world.
    • UTF-8 encoded text can be displayed on a variety of browsers that support UTF8 character sets in various countries. For example, if it is a UTF8 code, it can display Chinese in the foreigner's English ie, without requiring them to download IE's Chinese language support package. Therefore, for the more English forum, use GBK each character occupies 2 bytes, and the use of UTF-8 English is only a single byte.
    • UTF8 is an international code, its versatility is better, foreigners can also browse the forum

In general, the domestic system if you want to save Chinese characters, will generally choose to use the GBK character set, if you want to do the site, such as the global accessible system, then the general choice UTF-8.

2. Which character sets in the database need to be set?

The database is divided between the client character set and the database server character set .

Oracle also has two server character sets: regular character sets (database character sets in general) and national character sets

1. Character set in the general sense (database character set in the general sense):

(1) used to store char, VARCHAR2, CLOB, long and other types of data

(2) to indicate such as table name, column name, and PL/SQL variable, etc.

(3) used to store SQL and PL + + program units, etc.

(4) Generally: Al32utf8 or ZHS16GBK

2. National Character Set:

(1) to store nchar, NVARCHAR2, NCLOB and other types of data

(2) The national character set is essentially the additional character set chosen for Oracle, primarily to enhance the character processing capabilities of Oracle, since the nchar data type provides support for the use of fixed-length multibyte encoding in Asia, and the database character set is not. The national character set is redefined in oracle9i and can only be selected in Af16utf16 and UTF8 in Unicode encoding, and the default value is Af16utf16

3. Character Set viewing methods

Database Character Set: SELECT * from Nls_database_parameters;

Client Character Set: SELECT * from Nls_instance_parameters;

The database character set is represented in the following way:

Simplified Chinese_china. Al32utf8

Simplified Chinese_china. Zhs16gbk

If the client character set and the database character set are inconsistent, the following error is indicated when logging in via Plsql:

4. Client Character Set setting method

32-bit client: hkey_local_machine\software\oracle\

64-bit client: hkey_local_machine\software\wow6432node\oracle\key_oraclient11g_home1

5. What is the recommended character set?

Database Character set: Simplified Chinese_china. ZHS16GBK (most of the domestic database or Oracle, if the site is still recommended to use the UTF-8 character set)

National Character set: Simplified Chinese_china. Al16utf16

Client Character set: Simplified Chinese_china. Zhs16gbk

Web page Character set: UTF-8

After the experiment, there will be no garbled characters.

Reference article:

1. Oracle character set viewing and modification

Sdjnzqr
Source: http://www.cnblogs.com/sdjnzqr/
Copyright: This article is owned by the author and the blog Park
Reprint: Welcome reprint, but without the consent of the author, this paragraph must be retained; The original link must be given in the article; otherwise, legal liability
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.