Solve Chinese garbled characters in Oracle databases in Linux

Source: Internet
Author: User

Solve Chinese garbled characters in Oracle databases in Linux
Chinese garbled characters are displayed in Oracle databases in Linux

1. Cause of garbled Oracle database:
The operating system is consistent with the server, but the client and server character set are inconsistent.
The client is the same as the server, but the operating system is different from the server.
2. solution:
Set relevant character sets to ensure that the operating system, client, and database server are identical.
3. Applicable situations:
Set the character set of the client to be the same as that of the server. If the server's character set is UTF8 (we recommend that you use this character set when creating a database, which is compatible with both Chinese and English)

1) view the operating system Character Set

# localeLANG=zh_CN.UTF-8LC_CTYPE="zh_CN.UTF-8"LC_NUMERIC="zh_CN.UTF-8"LC_TIME="zh_CN.UTF-8"LC_COLLATE="zh_CN.UTF-8"LC_MONETARY="zh_CN.UTF-8"LC_MESSAGES="zh_CN.UTF-8"LC_PAPER="zh_CN.UTF-8"LC_NAME="zh_CN.UTF-8"LC_ADDRESS="zh_CN.UTF-8"LC_TELEPHONE="zh_CN.UTF-8"LC_MEASUREMENT="zh_CN.UTF-8"LC_IDENTIFICATION="zh_CN.UTF-8"LC_ALL=

Check that the default is zh_CN.UTF-8, And the rhel7 configuration file is locale. conf

# vi /etc/locale.confLANG="zh_CN.UTF-8"

2) view the database Character Set
$ Su-oracle

SQL> select userenv('language') from dual;USERENV('LANGUAGE')----------------------------------------------------AMERICAN_AMERICA.AL32UTF8

3) edit the linux NLS_LANG variable

$ vi .bash_profile # .bash_profile# Get the aliases and functionsif [ -f ~/.bashrc ]; then        . ~/.bashrcfi# User specific environment and startup programsPATH=$PATH:$HOME/.local/bin:$HOME/binexport PATHexport ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=/u01/app/oracle/product/11.2.0/dbhome_1 export ORACLE_SID=orclexport PATH=$ORACLE_HOME/bin:$PATH export LD_LIBRARY_PATH=$ORACLE_HOME/libLANG=zh_CN.UTF-8; export LANG#NLS_LANG='SIMPLIFIED CHINESE_CHINA.AL32UTF8'; export NLS_LANGNLS_LANG='AMERICAN_AMERICA.AL32UTF8'; export NLS_LANG

3) oracle user, temporary change environment variable for en_US.UTF-8

$ su - oracle $ export  LANG=en_US.UTF-8$ env |grep LANGNLS_LANG=AMERICAN_AMERICA.AL32UTF8LANG=en_US.UTF-8

Note: The Character Set of the client is consistent with that of the oracle database.

Sqlplus Verification:

SQL> select USERNAME, ACCOUNT from AP_INTE_USR; USERNAME ACCOUNT ---------------------- -------------------------- app test_app app testyin

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.