1. Composition of the NLS_LANG Parameter
The NLS_LANG parameter consists of the following parts:
NLS_LANG = <Language >_< Territory>. <Clients Characterset>
The meanings of NLS_LANG are as follows:
LANGUAGE:
-Oracle message language
-Display month and day in date
Specified by TERRITORY
-Currency and Number Format
-Habits of regions and computing weeks and dates
CHARACTERSET:
-Control character sets used by Client Applications
Usually set or equal to the client (such as Windows) code page
Or set the unicode application to UTF8.
Run the chcp command to view the current system code page on Windows:
E:/> chcp
Active Code Page: 936
The code page 936 is also the Chinese Character Set GBK. on Microsoft's official site, we can be subject to specific encoding rules for the 936 code page. refer to the following link:
Http://www.microsoft.com/globaldev/reference/dbcs/936.htm
2. view the NLS_LANG Method
Windows:
Echo % NLS_LANG %
For example:
E:/> echo % NLS_LANG %
AMERICAN_AMERICA.ZHS16GBK
Unix usage:
Env | grep NLS_LANG
For example:
/Opt/oracle> env | grep NLS_LANG
NLS_LANG = AMERICAN_CHINA.ZHS16GBK
Windows client settings, you can change NLS_LANG in the Registry, the specific key value is located in:
HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/HOMExx/
Xx indicates the system number when multiple ORACLE_HOME exists.
3. view the current character set parameter settings of the database
SELECT * FROM v $ nls_parameters;
4. view available Character Set parameter settings in the database
SELECT * FROM v $ nls_valid_values;
5. How to set the client NLS_LANG
Windows:
# Common Chinese character sets
Set NLS_LANG = SIMPLIFIED CHINESE_CHINA.ZHS16GBK
# Common unicode character sets
Set NLS_LANG = american_america.AL32UTF8
You can change the registry key value to set permanently.
HKEY_LOCAL_MACHINE/SOFTWARE/ORACLE/HOMExx/NLS_LANG
Unix:
# Common unicode character sets
Export NLS_LANG = american_america.AL32UTF8
# Common Chinese character sets
Export NLS_LANG = "Simplified Chinese_china". ZHS16GBK
You can edit the bash_profile file for permanent settings.
Vi. bash_profile
NLS_LANG = "Simplified Chinese_china". ZHS16GBK export NLS_LANG
# Make the bash_profile settings take effect
Source. bash_profile
Refer:
Http://www.eygle.com/special/NLS_CHARACTER_SET_04.htm