数据库服务器字符集select * from nls_database_parameters,其来源于props$,是表示数据库的字符集。
SQL> select * from nls_database_parameters; PARAMETER VALUE ------------------------------ ------------------------- NLS_LANGUAGE AMERICAN NLS_TERRITORY AMERICA NLS_CURRENCY $ NLS_ISO_CURRENCY AMERICA NLS_NUMERIC_CHARACTERS ., NLS_CHARACTERSET ZHS16GBK NLS_CALENDAR GREGORIAN NLS_DATE_FORMAT DD-MON-RR NLS_DATE_LANGUAGE AMERICAN NLS_SORT BINARY NLS_TIME_FORMAT HH.MI.SSXFF AM PARAMETER VALUE ------------------------------ ------------------------------------ NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR NLS_DUAL_CURRENCY $ NLS_COMP BINARY NLS_LENGTH_SEMANTICS BYTE NLS_NCHAR_CONV_EXCP FALSE NLS_NCHAR_CHARACTERSET UTF8 NLS_RDBMS_VERSION 11.2.0.1.0
客户端字符集环境select * from nls_instance_parameters,其来源于v$parameter,表示客户端的字符集的设置,可能是参数文件,环境变量或者是注册表
1 SQL> select * from nls_instance_parameters; 2 3 PARAMETER VALUE 4 ------------------------------------------------------------ ---------------------------- 5 NLS_LANGUAGE SIMPLIFIED CHINESE 6 NLS_TERRITORY CHINA 7 NLS_SORT 8 NLS_DATE_LANGUAGE 9 NLS_DATE_FORMAT 10 NLS_CURRENCY 11 NLS_NUMERIC_CHARACTERS 12 NLS_ISO_CURRENCY 13 NLS_CALENDAR 14 NLS_TIME_FORMAT 15 NLS_TIMESTAMP_FORMAT 16 17 PARAMETER VALUE 18 ------------------------------------------------------------ ---------------------------- 19 NLS_TIME_TZ_FORMAT 20 NLS_TIMESTAMP_TZ_FORMAT 21 NLS_DUAL_CURRENCY 22 NLS_COMP BINARY 23 NLS_LENGTH_SEMANTICS BYTE 24 NLS_NCHAR_CONV_EXCP FALSE 25 26 已选择17行。
会话字符集环境 select * from nls_session_parameters,其来源于v$nls_parameters,
SQL> select * from nls_session_parameters; PARAMETER VALUE ------------------------------------------------------------ ------------------------------- NLS_LANGUAGE SIMPLIFIED CHINESE NLS_TERRITORY CHINA NLS_CURRENCY ? NLS_ISO_CURRENCY CHINA NLS_NUMERIC_CHARACTERS ., NLS_CALENDAR GREGORIAN NLS_DATE_FORMAT DD-MON-RR NLS_DATE_LANGUAGE SIMPLIFIED CHINESE NLS_SORT BINARY NLS_TIME_FORMAT HH.MI.SSXFF AM NLS_TIMESTAMP_FORMAT DD-MON-RR HH.MI.SSXFF AM PARAMETER VALUE ------------------------------------------------------------ ------------------------------- NLS_TIME_TZ_FORMAT HH.MI.SSXFF AM TZR NLS_TIMESTAMP_TZ_FORMAT DD-MON-RR HH.MI.SSXFF AM TZR NLS_DUAL_CURRENCY ? NLS_COMP BINARY NLS_LENGTH_SEMANTICS BYTE NLS_NCHAR_CONV_EXCP FALSE 已选择17行。
表示会话自己的设置,可能是会话的环境变量或者是alter session完成,如果会话没有特殊的设置,将与nls_instance_parameters一致。
客户端的字符集要求与服务器一致,才能正确显示数据库的非Ascii字符。如果多个设置存在的时候,alter session>环境变量>注册表>参数文件字符集要求一致,但是语言设置却可以不同,语言设置建议用英文。如字符集是zhs16gbk,则nls_lang可以是American_America.zhs16gbk。
注:
1.通过alter system set nls_language='AMERICAN' scope=spfile; 可以更改nls_database_parameters和nls_instance_parameters的nls_language
2. 通过alter session set nls_language='SIMPLIFIED CHINESE'; 可以更改nls_session_parameters的nls_language