0
  1. I run a simple query with oracle database 11g on CentOS, but I got wrong CHARACTER SET.
SQL> select col_name from table_name where rownum <= 1;

col_name 
--------------------------------------------------------------------------------
¸ñ귎Ϊʯҩ¼¯΅mRNAт¹ےࠃ萮Ŀ802³µ¼乄լ¾»»¯ůͨ¹¤³̡£
  1. I get database CHARACTER SET as follows
SQL> select userenv('language') from dual;

USERENV('LANGUAGE')
----------------------------------------------------
AMERICAN_AMERICA.ZHS16GBK
  1. Set CHARACTER SET to client
    echo 'export NLS_LANG="AMERICAN_AMERICA.ZHS16GBK"'>>/etc/profile && source /etc/profile
  2. rerun query SQL, but also got problem, How can I resolve it.
distinct
  • 29
  • 3

1 Answers1

1

Check your terminal settings with locale charmap or echo $LANG and verify if it matches with ZHS16GBK.

It is not required to use the same character set as your database. Using NLS_LANG=AMERICAN_AMERICA.AL32UTF8 and UTF-8 in your terminal will also work. It is important that NLS_LANG matches your terminal character set.

See also OdbcConnection returning Chinese Characters as "?"

Wernfried Domscheit
  • 54,457
  • 9
  • 76
  • 110
  • It works perfect when I set `export NLS_LANG="AMERICAN_AMERICA.AL32UTF8" export LANG="zh_CN.UTF-8"` on my terminal – distinct May 12 '22 at 03:33