Get the App
SLTechnology News&Howtos  ›  Database  › 

[oracle] solve the problem of Chinese garbled code in oracle under centos 7

Shulou Source: shulou.com Published: 2022-06-01 16:09:54 10月01日 Update

First of all, the reason for the formation of Chinese garbled code is due to the disunity of the character set, different character sets are bound to appear garbled in the process of conversion, of course, it can be converted. Therefore, in order to solve the problem of Chinese garbled code, the idea is to unify the character sets involved in the process of input, storage and display into one. The first prerequisite for oracle is to unify the character set of the server and the client segment. If the problem can not be solved, it is also necessary to unify the character set of the system, or even the character set used for importing or inputting data.

After reading some materials on the Internet, it is said that the risk of modifying the character set of the server is relatively high. Indeed, it is easy to say that if it is the server of the online project, the consequences of modifying the character set of the server are unbearable. Nonsense, I will post my solution below.

1. Garbled code problem

At the beginning, the table is created through the sql statement, and the data is inserted, and finally select is carried out. The following questions are always displayed in the command interface:

2. Query the character set of the server

SQL > select userenv ('language') from dual

The following results are displayed:

AMERICAN_AMERICA.WE8MSWIN1252

This character set is rather strange. I've never seen it before, but there are too many things I haven't seen before. since people design such a character set by default, it should have its advantages.

3. View the character set set by the client in the configuration file

Vi / home/oracle/.bash_profile

The display results are as follows:

Export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK

It turns out that when I installed oracle, I set the character set of the client to AMERICAN_AMERICA.ZHS16GBK. If the character set of the server is different from that of the client, it is bound to make an error. Change the character set of the client to AMERICAN_AMERICA.WE8MSWIN1252, and re-execute the program. The delightful result appears:

Tags: Character character set client service garbled problem end unified result Chinese inevitable data server input different pleasing to the eye same feast for the eye feast for the eye something Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno MariaDB macOS Apple vpn Microsoft