简体   繁体   English

配置Oracle DB默认采用双字节字符集

[英]Configure an Oracle DB to assume double byte character sets by default

I have set up an Oracle DB with AL32UTF8. 我已经使用AL32UTF8设置了一个Oracle DB。 I am able to put DBCS characters (chinese, high-ascii, etc.) in the DB when using a tool such as SQLPlus and SQLDeveloper. 当使用SQLPlus和SQLDeveloper等工具时,我可以在DB中放置DBCS字符(chinese,high-ascii等)。

However, when my application, which is using the Oracle Instant Client, attempts to put data into the DB, DBCS characters are turned into ? 但是,当我的应用程序(使用Oracle Instant Client)尝试将数据放入数据库时​​,DBCS字符会变成? marks. 分数。 I was able to solve this issue and get things working by doing this: export NLS_LANG='.AL32UTF8' on the machine (CentOS) running my application. 我能够解决这个问题并通过这样做来解决问题:在运行我的应用程序的机器(CentOS)上导出NLS_LANG ='。AL32UTF8'。 The DB is on a separate machine. 数据库位于单独的计算机上。 With the above fix, I would need to set NLS_LANG on all clients. 通过上面的修复,我需要在所有客户端上设置NLS_LANG。

What I want to be able to do (if possible) is configure the DB so that it assumes the client is using NLS_LANG = '.AL32UTF8' by default, so that NLS_LANG does not have to be set on all clients. 我希望能够做的(如果可能的话)是配置数据库,使其假定客户端默认使用NLS_LANG ='。AL32UTF8',这样就不必在所有客户端上设置NLS_LANG。 Is this possible? 这可能吗? If so, how? 如果是这样,怎么样?

This settings belongs to client only, if client assume that default is some latin, you can't override it somewhere else. 此设置仅属于客户端,如果客户端假定默认值为拉丁语,则无法在其他位置覆盖它。 On the other hand, you can always do ALTER SESSION to set required NLS_LANG option in your application. 另一方面,您始终可以在应用程序中执行ALTER SESSION以设置所需的NLS_LANG选项。

Setting up an AFTER LOGON trigger is the only way for the database layer to positively control NLS parameters. 设置AFTER LOGON触发器是数据库层积极控制NLS参数的唯一方法。 Settings inherited via the client environment will override those set in the server environment. 通过客户端环境继承的设置将覆盖服务器环境中设置的设置。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM