下面这段话说明如果数据库字符集是英文,例如WE8MSWIN1252,想要存储中文是会出现问题的:
When the databasecharacter set and the client character set are the same, Oracle assumes that thedata being sent or received is of the same character set, so no validations orconversions are performed. Although the benefit of this scenariois betterperformance, misuse can lead to possible data inconsistency problems, such asstoring data from another character set that is different from the databasecharacter set.
For example, yourdatabase character set is US7ASCIIand you are using Simplified Chinese Windowsas your client terminal. By setting NLS_LANGto SIMPLIFIED
CHINESE_HONGKONG.US7ASCIIasthe client character set, it is possible for you to store
multibyte SimplifiedChinese characters inside a single byte database. This means that Oracle willtreat these characters as single-byte US7ASCIIcharacters, and therefore, allSQL string manipulation functions such as SUBSTRor LENGTHwill be based on bytesrather than characters. All of your non-ASCII characters could be lostfollowing an export and import into another database.
3.3. Windows下常用客户端设置PL/SQL Developer
1、影响PL/SQL DEVELOPER字符集显示的要素
OS 系统当前字符集使用chcp查看coding page,936表示操作系统当前字符集为简体中文,同ZHS16GBK..
ORACLE注册表在ORACLE目录下NLS_LANG,如AMERICAN_AMERICA.ZHS16GBK
该键值默认读取OS系统当前字符集,当然可以修改。
系统环境变量NLS_LANG环境变量影响DOS窗口、sql*plus、PL/SQL DEVELOPER等应用.
ORACLE数据库字符设置select * from NLS_DATABASE_PARAMETERS n where n.PARAMETER='NLS_CHARACTERSET';
PARAMETER VALUE
NLS_CHARACTERSET ZHS16GBK
PL/SQL DEVELOPER菜单中TOOLS中首选项的'unicode support'若选中此项,将从 Oracle Server 中按原样获取 Unicode 数据,并将其显示为 Unicode
文本。若禁用此项,则来自服务器的 Unicode 数据将根据 Oracle HomeRegistry 的
NLS_LANG 键转换为 Oracle Client 的字符集。
写入中文时一定要指定环境变量NLS_LANG(注意是环境变量,不是注册表),只要指定了,输入中文便能正确写入,无其他要求。
4. 获取语言字符集信息
数据库服务器NLS_DATABASE_PARAMETERS(props$):
§ Parameter(NLS_CHARACTERSET,NLS_NCHAR_CHARCTERSET)
§ VALUE
查询结果中NLS_CHARACTERSET表示字符集,NLS_NCHAR_CHARACTERSET表示国家字符集
客户端字符集NLS_INSTANCE_PARAMETERS(来自于V$NLS_PARAMETERS):
§ 参数(被显式设置的初始化参数)
§ 值
会话字符集环境NLS_SESSION_PARAMETERS:
§ 参数(session parameters)
§ VALUE
V$NLS_VALID_VALUES(显示NLS data boot file,包括可能不支持的或者外部用的定义)
§ Parameter(language,sort,territory,characterset)
§ VALUE