SUSE10中Oracle10g存储中文数据

需要做到如下几点:
相关设置为UTF-8,要是用GBK的话适当修改即可。SUSE10的locale设置为zh_CN.UTF-8,在安装数据库时语言选择简体中文和英语,选择字符集为AL32UTF8,这样可存储多国数据(包括中文),但相较于ZHS16GBK会增加数据库的体积,因为中文在UTF-8里占3个字节,ZHS16GBK里占2个字节。这是安装完毕数据库中关于语言和字符集的一些设置:
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 AL32UTF8
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 AL16UTF16
NLS_RDBMS_VERSION 10.2.0.1.0

安装完毕数据库后,在用户的根目录下的.profile中增加两行:
NLS_LANG='SIMPLIFIED CHINESE_CHINA.AL32UTF8'
export NLS_LANG
然后,source .profile,使设置生效。连接数据库,查看效果:
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

解释一下,NLS_LANGUAGE=SIMPLIFIED CHINESE,可以令Oracle数据库显示中文提示等,NLS_TERRITORY =CHINA,可以让数据库以中文的格式存储月份,例如“11-12月-1997”这样的。

你可能感兴趣的:(oracle,oracle10g,休闲,suse10,存储中文数据)