Oracle字符集研究8654.pptx
《Oracle字符集研究8654.pptx》由会员分享,可在线阅读,更多相关《Oracle字符集研究8654.pptx(50页珍藏版)》请在得力文库 - 分享文档赚钱的网站上搜索。
1、ORACLEORACLE字符集研究字符集研究DextrysCo.,Ltd.Kelson CongDBA Team Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.2飞刀,又见飞刀飞刀,又见飞刀什么是字符集字符集就是按照一定的字符编码方案,对一组特定的符号,分别赋予不同数值编码的集合。Oracle数据
2、库最早支持的编码方案是US7ASCII。Oracle的字符集命名遵循以下命名规则:即:比如:ZHS16GBK表示采用GBK编码格式、16位(两个字节)简体中文字符集 Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.3飞刀,又见飞刀飞刀,又见飞刀字符编码方案单字节编码单字节7位字符集,可以定义128个
3、字符,最常用的字符集为US7ASCII单字节8位字符集,可以定义256个字符,适合于欧洲大部分国家例如:WE8ISO8859P1(西欧、8位、ISO标准8859P1编码)Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.4飞刀,又见飞刀飞刀,又见飞刀多字节编码变长多字节编码某些字符用一个字节表示,其它
4、字符用两个或多个字符表示,变长多字节编码常用于对亚洲语言的支持,例如日语、汉语、印地语等例如:AL32UTF8(其中AL代表ALL,指适用于所有语言)、zhs16cgb231280 Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.5飞刀,又见飞刀飞刀,又见飞刀定长多字节编码每一个字符都使用固定长度字
5、节的编码方案,目前oracle唯一支持的定长多字节编码是AF16UTF16,也是仅用于国家字符集 Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.6飞刀,又见飞刀飞刀,又见飞刀unicode编码Unicode是一个涵盖了目前全世界使用的所有已知字符的单一编码方案,也就是说Unicode为每一个字符提
6、供唯一的编码。UTF-16是unicode的16位编码方式,是一种定长多字节编码,用2个字节表示一个unicode字符,AF16UTF16是UTF-16编码字符集。Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.7飞刀,又见飞刀飞刀,又见飞刀UTF-8是unicode的8位编码方式,是一种变长多字节
7、编码,这种编码可以用1、2、3个字节表示一个unicode字符,AL32UTF8,UTF8、UTFE是UTF-8编码字符集 Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.8当一种字符集(字符集A)的编码数值包含所有另一种字符集(字符集B)的编码数值,并且两种字符集相同编码数值代表相同的字符时,则字
8、符集A是字符集B的超级,或称字符集B是字符集A的子集。Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.9Oracle8i和oracle9i官方文档资料中备有子集-超级对照表(subset-supersetpairs),例如:WE8ISO8859P1是WE8MSWIN1252的子集。由于US7ASCI
9、I是最早的Oracle数据库编码格式,因此有许多字符集是US7ASCII的超集,例如WE8ISO8859P1、ZHS16CGB231280、ZHS16GBK都是US7ASCII的超集。Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.10 Copyright,Suzsoft Co.,Ltd.Confi
10、dential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.11查看字符集的工具:LBUILDER Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprie
11、tary Information.All Rights Reserved.12 Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.13数据库字符集数据库字符集数据库字符集(oracle服务器端字符集)数据库字符集在创建数据库时指定,在创建后通常不能更改。在创建数据库时,可以指定字符集(CHARACTE
12、RSET)和国家字符集(NATIONALCHARACTERSET)。Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.14数据库字符集数据库字符集字符集用来存储CHAR,VARCHAR2,CLOB,LONG等类型数据用来标示诸如表名、列名以及PL/SQL变量等用来存储SQL和PL/SQL程序单元等 C
13、opyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.15数据库字符集数据库字符集国家字符集:用以存储NCHAR,NVARCHAR2,NCLOB等类型数据国家字符集实质上是为oracle选择的附加字符集,主要作用是为了增强oracle的字符处理能力,因为NCHAR数据类型可以提供对亚洲使用定长多字节编码的支
14、持,而数据库字符集则不能。国家字符集在oracle9i中进行了重新定义,只能在unicode编码中的AF16UTF16和UTF8中选择,默认值是AF16UTF16 Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.16数据库字符集数据库字符集讨论:1、什么情况下用CHAR,NCHAR?2、如何决定数据
15、库字符集?Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.17数据库字符集数据库字符集可以查询以下数据字典或视图查看字符集设置情况nls_database_parameters、props$、v$nls_parameters查询结果中NLS_CHARACTERSET表示字符集,NLS_NCHAR_C
16、HARACTERSET表示国家字符集 Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.18数据库字符集数据库字符集 Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyr
17、ight,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.19数据库字符集数据库字符集如何修改服务器端字符集AlterdatabasecharactersetZHS16GBK此方法慎用!千万不要通过修改PROPS$的方式修改新的字符集一定是老字符集的超集 Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confid
18、ential and Proprietary Information.All Rights Reserved.20数据库字符集数据库字符集 Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.21数据库字符集数据库字符集 Copyright,Suzsoft Co.,Ltd.Confidential an
19、d Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.22客户端字符集客户端字符集客户端字符集定义了客户端字符数据的编码方式,任何发自或发往客户端的字符数据均使用客户端定义的字符集编码,客户端可以看作是能与数据库直接连接的各种应用,客户端字符集是通过设置NLS_LANG参数来设定的。Copyright,Suzsoft Co.,Ltd.Confidential and Proprieta
20、ry Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.23客户端字符集客户端字符集NLS_LANG参数格式NLS_LANG=LANGUAGE_TERRITORY.CHARACTERSETLanguage:显示oracle消息,校验,日期命名Territory:指定默认日期、数字、货币等格式Clientcharacterset:指定客户端将使用的字符集例如:NLS_LANG=AMERICAN_AMERICA.
21、US7ASCIIAMERICAN是语言,AMERICA是地区,US7ASCII是客户端字符集 Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.24客户端字符集客户端字符集客户端字符集设置方法1)UNIX环境$NLS_LANG=“simplifiedchinese”_china.zhs16gbk$ex
22、portNLS_LANG编辑oracle用户的profile文件2)Windows环境编辑注册表HKEY_LOCAL_MACHINE-SOFTWARE-ORACLE-HOME0(9i)HKEY_LOCAL_MACHINE-SOFTWARE-ORACLE-KEY_OraDb10g_home1(10g)Copyright,Suzsoft Co.,Ltd.Confidential and Proprietary Information.All Rights Reserved.Copyright,Dextrys Co.,Ltd.Confidential and Proprietary Informat
- 配套讲稿:
如PPT文件的首页显示word图标,表示该PPT已包含配套word讲稿。双击word图标可打开word文档。
- 特殊限制:
部分文档作品中含有的国旗、国徽等图片,仅作为作品整体效果示例展示,禁止商用。设计者仅对作品中独创性部分享有著作权。
- 关 键 词:
- Oracle 字符集 研究 8654
限制150内