Character Set analysis that affects Oracle Chinese Character Display

Source: Internet
Author: User
Tags microsoft access database
-------------------------------------- Search for a blog on the Internet to facilitate future viewing --------------------------------------------------------------------

There are many users who use ORACLE as a database management platform in large and medium-sized database management systems at home and abroad. Oracle is beyond review in terms of both database management capabilities and security. However, it brings a lot of trouble to Chinese users in displaying Chinese characters. I have been engaged in Oracle Database Management for many years, users in the surrounding area and users in other places often receive support letters that reflect Chinese character display problems in Oracle databases. The main phenomenon is that Chinese characters are displayed as unidentifiable garbled characters, leading to the unavailability of a large amount of original information. This article will discuss the causes and solutions of this problem for your reference.
  
  1. Cause Analysis
Through the analysis of user feedback, it is found that improper Character Set setting is a key issue affecting Chinese character display in the Oracle database. So how will the character set take a while? Character Set is set by Oracle to adapt to text display in different languages. The character sets used for displaying Chinese characters include zhs16cgb231280, us7ascii, and we8iso8859p1. The character set must not only exist on the server, but also be registered on the client. On the server side, the character set is specified when oracle is installed. The character set registration information is stored in the V $ nls_parameters table of the Oracle database dictionary. on the client side, the character set is divided into two situations, one scenario is SQL * NET 2.0 or earlier. The character set is in Oracle under the Windows System directory. the INI file is registered. In another case, SQL * NET 2.0 or later (32-bit) versions, the character set is registered in the Windows system registry. To correctly display Chinese characters in the Oracle database on the client, the character set on the server must be consistent with that on the client. Secondly, the data Character Set loaded to the Oracle database must be consistent with the character set specified on the server. Therefore, we classify user problems and generate the following reasons for Chinese Character Display exceptions:
  
1. 1. The character set specified by the server is different from the customer character set, and is consistent with the loaded data character set.
  
This is the most common case. You only need to set the character set of the client correctly. For the solution, see 2.1.
  
The character set specified by the server is the same as the customer character set and is inconsistent with the loaded data character set.
  
This type of problem generally occurs when the Oracle version is upgraded or the system is reinstalled with a different character set than the original server, and the restored backup data is still detached from the original character set, and load the data that is detached from other Oracle databases that use different character sets. In both cases, Chinese characters cannot be displayed regardless of whether the server and client character sets are consistent. For the solution, see 2.2.
  
1.3 The character set specified by the server is different from the customer character set and is inconsistent with the input data character set.
  
In this case, Chinese characters are entered from the client when the character set of the client is inconsistent with that of the server. The entered information cannot display Chinese characters even if the client character set is changed correctly. For the solution, see 2.3.
  
  2. Solution
The following solutions are provided for the above three situations. For ease of description, assuming that the client uses the Windows 95/98 environment and has successfully configured the TCP/IP protocol, the SQL * Net and SQL * pluse products of Oracle are installed.
  
2.1 set the client character set to be consistent with the server Character Set
  
Assume that the current server uses the us7ascii character set.
  
(1) view server-side character sets
  
Log on to a legal Oracle user through SQL * Plus on the client or server and execute the following SQL statements:
  
SQL> select * from V $ nls_parameters
  
Parameter Value
  
Nls_language American
  
Nls_territory America
  
... .....
  
Nls_characterset us7ascii
  
Nls_sort binary
  
Nls_nchar_characterset us7ascii
  
From the list above, we can see that the character set of the server-side Oracle database is 'us7ascii '.
  
(2) configure the client according to the server Character Set
  
There are two configuration methods:
  
Specify
  
When installing the Oracle client software, select the same character set (in this example, us7ascii) as the Oracle server.
  
How to modify Registration Information
  
The SQL * Net version selected by the Oracle client is divided into the following two situations:
  
A. The client is SQL * NET 2.0 or earlier
  
Go to the Windows System directory, edit the Oracle. ini file, replace the original character set with us7ascii, and restart the computer. The settings take effect.
  
B. The client is SQL * NET 2.0 or later.
  
Run regedit in Win98. Select HKEY_LOCAL_MACHINE in step 1, select Software in step 2, select oracle in step 3, and select nls_lang in step 4, the word set (in this example, american_american.us7ascii) that is the same as that of the server ).

2.2 The forcibly loaded data character set is consistent with the server-side character set
  
Assume that the character set for data to be loaded from the original Oracle database is us7ascii, and the current ORACLE Server character set is we8iso8859p1.
  
Three solutions are provided below:
  
(1) reinstall oracle on the server
  
When you reinstall Oracle, select the same character set (in this example, us7ascii) as the original unload data ).
  
Load the original detached data.
  
This situation only applies to empty databases and data with the same character set.
  
(2) Forcibly modify the current character set of Oracle on the server
  
Before using the IMP command to load data, log on to the system DBA using SQL * Plus on the client and run the following SQL statement to modify the character set of the current Oracle database:
  
SQL> Create Database Character Set us7ascii
  
* Create Database Character Set us7ascii
  
Error at line 1:
  
ORA-01031: insufficient privileges
  
You will find that the above error message is prompted during statement execution. Ignore this. In fact, the character set of the Oracle database has been forcibly changed to us7ascii, and then load data using the IMP command. After the data is loaded, shut down the database and start up the database. log on to the Oracle database with a valid user and run select * from V $ nls_parameters at the SQL> command prompt, you can see that the character set of the Oracle database has been restored. When you view a table with Chinese character data, the Chinese character is correctly displayed.
  
(3) Use Data Format dump to avoid character set restrictions
  
This method is mainly used to load different character sets of external Oracle databases. The method is as follows:
  
First, load the data to the server with the same character set, then use the Conversion Tool to unload the database in FOXBASE format or ACCESS format, and then transfer it to the Oracle database of different character sets, this avoids Oracle Character Set troubles. Currently, there are many database format conversion tools, such as pipeline provided by power builder5.0 and later versions, and data import/export functions provided by Microsoft Access database. For more information about the conversion method, see. .
  
2.3 replace Chinese characters with matching character sets
  
There is no good way to match the character set of the client and the server first, and then replace the Chinese character part with the original Chinese character pattern.

----------------- Learning convenience only

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.