The Oracle tutorial is: Analysis of garbled characters in the Oracle 8i Character Set and solutions. I. Problem Description
SQL plus worksheet is an SQL statement editor for window graphic interfaces. This tool is very popular with SQL/plus for users who prefer Window Interfaces rather than character interfaces. However, after Oracle 8i, if the English character set is selected when Oracle 8i is installed, for China, the simplified Chinese character set (zhs16gbk) is usually selected. After the installation is successful, run SQL plus WorksheetProgram. All Chinese characters are displayed and the query results are garbled.
Ii. Problem Analysis
At first, the problem occurs. First, it is suspected that the character set is incorrect during installation, that is, the simplified Chinese character set is not correctly set. First, check the database character set. In SQL/plus, run the following SQL statement to check the character set of the connected database:
The query results show that the character set selected during database installation is zhs16gbk, which indicates that the character set is correctly set during installation. Step 2: Check the client registry and open the Registry Editor (Regedit). In HKEY_LOCAL_MACHINE/software/Oracle/nls_lang, the Oracle client character set is american_america.zhs16gbk, the setting is also completely correct, which can eliminate the problem of incorrect Character Set settings on the client. At the same time, the query character set in SQL/plus is displayed completely normal on the same client machine. This also shows that it is not a problem in Character Set setting, but a problem in the system program SQL/plus worksheet.
In versions earlier than Oracle 8i, this has never been the case. This should be related to the Oracle version, we know that a significant difference between Oracle 8i and earlier versions is that most of the Oracle system programs use Java drivers. In fact, this is the root cause of Character Set garbled characters. A non-Java-driven program, such as SQL * Plus, has a system parameter nls_lang. this parameter is set in the environment variable in the Unix system and in the Registry in the Windows operating system, this parameter determines the character set of the client application. For Java-based applications, such as SQL * Plus worksheet, The nls_lang parameter does not have any effect on such programs.
Iii. Solutions
After finding out the cause of the problem, we will discuss how to solve it. For all tools in Oracle Enterprise Manager, the configuration file name is dbappscfg. properties. You can modify the file to solve the above problem. The file is located in the $ ORACLE_HOME \ sysman \ config directory. open the file in any text editor and find this file,
Remove the annotator # and change it to sqlplus_nls_lang = american_america.zhs16gbk.
For Windows operating systems, you also need to modify one item. Find # sqlplus_systemroot = c: \ winnt40 in the file, remove the annotator, and change it to the operating system home directory of your machine. If the main directory of the operating system is in winnt of drive D, change it to sqlplus_systemroot = D: \ WINNT.
Modifications to the next item only apply to the Windows operating system, and are not required for the UNIX operating system. If this option is not modified in windows, the following error is prompted during system connection in Oracle Enterprise Manager:
Or
after modification, save the file and exit editing. Reconnect SQL plus worksheet to solve the character set garbled problem and display the correct simplified Chinese character set.