Chinese oracle database insert garbled

One.

Query the database coding

select userenv('language') from dual;

Query server encoding

select * from v$nls_parameters;

Launched sql query system coding

root@f096e625bcd3:/# locale
LANG=
LANGUAGE=
LC_CTYPE="POSIX"
LC_NUMERIC="POSIX"
LC_TIME="POSIX"
LC_COLLATE="POSIX"
LC_MONETARY="POSIX"
LC_MESSAGES="POSIX"
LC_PAPER="POSIX"
LC_NAME="POSIX"
LC_ADDRESS="POSIX"
LC_TELEPHONE="POSIX"
LC_MEASUREMENT="POSIX"
LC_IDENTIFICATION="POSIX"
LC_ALL=

You can see the current encoding format to POSIX, and this encoding format does not support Chinese

  Solution : locale -a Check the container for all locales

  

Use locale -a view the currently available character set, here we see C.UTF-8 and zn_CN.UTF-8, these two support Chinese character sets. If there is currently no zn_CN.UTF-8, may be used sudo apt-get -y install language-pack-zh-hans installation.

sudo apt-get -y install language-pack-zh-hans

 

 C.UTF-8 can support Chinese, just need to encode the container can C.UTF-8

    1. Temporary Modified:

     export LANG=zh_CN.UTF-8

root@f096e625bcd3:/#  export LANG=zh_CN.UTF-8
root@f096e625bcd3:/# locale
LANG=zh_CN.UTF-8
LANGUAGE=
LC_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=

    2. Permanent modification: Modify Dockerfile

      Add a line in the Dockerfile

      ENV LANG C.UTF-8

      Re-create docker mirror, docker run -ti [Mirror] executed after entering the container locale find encoding format has been modified to C.UTF-8, before the emergence of the Chinese file name garbled problem is gone.

  III. Modify oracle coding

1. Review the current database encoding

select userenv('language') from dual;
SQL> select userenv('language') from dual;

USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.AL32UTF8

2. Check the system NLS_LANG

echo $NLS_LANG

Setting NLS_LANG

export NLS_LANG=AMERICAN_AMERICA.AL32UTF8

success

Guess you like

Origin www.cnblogs.com/jiangfeilong/p/10926609.html