Character Set garbled summary query current database Character Set
BYS@bys1>select userenv('language') from dual;USERENV('LANGUAGE')----------------------------------------------------AMERICAN_AMERICA.AL32UTF8BYS@bys1>select * from nls_database_parameters;PARAMETER VALUE------------------------------ --------------------NLS_LANGUAGE AMERICANNLS_TERRITORY AMERICANLS_CURRENCY $NLS_ISO_CURRENCY AMERICANLS_NUMERIC_CHARACTERS .,NLS_CHARACTERSET AL32UTF8NLS_CALENDAR GREGORIANNLS_DATE_FORMAT DD-MON-RRNLS_DATE_LANGUAGE AMERICANNLS_SORT BINARYNLS_TIME_FORMAT HH.MI.SSXFF AMNLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXF F AMNLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZRNLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXF F AM TZRNLS_DUAL_CURRENCY $NLS_COMP BINARYNLS_LENGTH_SEMANTICS BYTENLS_NCHAR_CONV_EXCP FALSENLS_NCHAR_CHARACTERSET UTF8NLS_RDBMS_VERSION 11.2.0.1.0[oracle@bys001 ~]$ export NLS_LANG=AMERICAN_AMERICA.ZHS16GBK[oracle@bys001 ~]$ echo $NLS_LANGAMERICAN_AMERICA.ZHS16GBK
The display characters use the operating system character set. For example, in Chinese WIN, log on to English LINUX Using SSH, and then log on to the database using SQLPLUS for query. If the query result contains Chinese characters, it can be displayed. If you directly log on to the English LINUX system and use SQLPLUS to log on to the database for query, Chinese characters cannot be displayed normally. The client character set is set to let the database know the character set that we passed in the past, so that ORACLE can perform corresponding encoding ing when storing characters. In fact, garbled characters are caused by the fact that the operating system used to display characters does not find the corresponding characters in character encoding. The main cause of this phenomenon is: 1: the OS character encoding of the input operation is inconsistent with the queried OS character encoding, leading to garbled characters. 2: The client character set for the input operation (nls_lang) is different from the query client character set (nls_lang), which may also cause garbled or wrong characters to be returned for the query. Another question needs to be explained: In the above example, the same character set corresponds to different character encoding in different character sets. This is usually called incompatible or incompatible character sets, for example, zhs16gbk and al32utf8 store the same ascii code, but different Chinese characters. If the two character sets use the same character encoding for the same character set, we call it character compatibility. A large range is called a super character set of a small range. We usually encounter the situation of zhs16cgb231280 and zhs16gbk, which is the super of the former.