ORACLE 11g默认不区分大小写

发布于 2024-08-16 13:35:50 字数 317 浏览 9 评论 0原文

我在这篇文章中发现,从ORACLE 10g开始,有一种方法可以使用 ALTER SESSION 使特定的连接会话比较字符串不区分大小写,而不需要任何疯狂的 SQL 函数。

有谁知道,在 11g 中,是否有一种方法可以使数据库默认为所有新连接会话始终在此模式下运行,从而消除每次运行 ALTER SESSION 的需要你连接吗?

或者,您可以在连接字符串上指定一个附加参数来打开相同的功能?

I found in this article, that since ORACLE 10g, there is a way to make a particular connection-session compare strings case-insensitive, without needing any crazy SQL functions, using an ALTER SESSION.

Does anyone know if, in 11g, there might be a way to make the database to always operate in this mode by default for all new connection-sessions, thereby eliminating the need for running ALTER SESSIONs every time you connect?

Or perhaps, an additional parameter you could specify on your connection string that would turn the same on?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

蓝礼 2024-08-23 13:35:50

您只需使用 alter system set将文章中提到的 NLS_SORTNLS_COMP 参数设置为 Oracle init 文件中的值即可。 = <值>; 子句。

有关使用 alter system 命令的信息可以在 此处找到

这是一个关于正确用法的很好的链接 NLS_* 参数。请注意,NLS_SORT 参数的某些设置可能会导致性能问题,即当它未设置为 BINARY 时。 Oracle 文档指出:

将 NLS_SORT 设置为其他任何值
比 BINARY 导致排序使用
全表扫描,无论
优化器选择的路径。二进制
是例外,因为索引是
按照二进制顺序构建
键。因此优化器可以使用
满足 ORDER BY 子句的索引
当 NLS_SORT 设置为 BINARY 时。如果
NLS_SORT 设置为任何语言
排序,优化器必须包括
全表扫描和全排序
执行计划。

You could just set the NLS_SORT, NLS_COMP parameters mentioned in the article as the values in the the Oracle init file using the alter system set <parameter> = <value>; clause.

Info on using the alter system commands can be found here.

Here is a good link on the correct usage of the NLS_* parameters. Note that some settings of of the NLS_SORT parameter can/could cause performance issues, namely when it is not set to BINARY. The Oracle docs state:

Setting NLS_SORT to anything other
than BINARY causes a sort to use a
full table scan, regardless of the
path chosen by the optimizer. BINARY
is the exception because indexes are
built according to a binary order of
keys. Thus the optimizer can use an
index to satisfy the ORDER BY clause
when NLS_SORT is set to BINARY. If
NLS_SORT is set to any linguistic
sort, the optimizer must include a
full table scan and a full sort in the
execution plan.

浅黛梨妆こ 2024-08-23 13:35:50

当然可以!

让您友好的 DBA 设置这些参数:

ALTER SYSTEM SET NLS_COMP=LINGUISTIC SCOPE=SPFILE; 

ALTER SYSTEM SET NLS_SORT=BINARY_AI SCOPE=SPFILE; 

这摘自我关于 如何使 Oracle 不区分大小写

Sure you can!

Get your friendly DBA to set these parameters:

ALTER SYSTEM SET NLS_COMP=LINGUISTIC SCOPE=SPFILE; 

ALTER SYSTEM SET NLS_SORT=BINARY_AI SCOPE=SPFILE; 

This is taken from my short article on How to make Oracle Case Insensitive

半步萧音过轻尘 2024-08-23 13:35:50

我尝试使用登录触发器来发出这些命令来获取不区分大小写的查询:

execute immediate 'alter session set NLS_SORT=BINARY_CI';
execute immediate 'alter session set NLS_COMP=LINGUISTIC';

虽然这确实给了我 CI,但它也给我带来了令人难以置信的糟糕性能问题。我们有一个特别的表,如果没有这些设置,插入需要 2 毫秒。完成这些设置后,插入需要 3 秒。我通过多次创建和删除触发器确认了这一点。

我不知道在系统级别执行此操作(与使用触发器的会话级别相反)是否会产生影响。

I tried using a logon trigger to issue these commands to get case-insensitive queries:

execute immediate 'alter session set NLS_SORT=BINARY_CI';
execute immediate 'alter session set NLS_COMP=LINGUISTIC';

And while that did give me CI, it also gave me unbelievably bad performance issues. We have one table in particular that, without those settings, inserts take 2 milliseconds. With those settings in place, inserts took 3 seconds. I have confirmed this by creating and dropping the trigger multiple times.

I don't know if doing it at the system level, as opposed to the session level with a trigger, makes a difference or not.

盛夏已如深秋| 2024-08-23 13:35:50

我在 11g r2 中发现插入和 nls 也存在相同的性能问题!幸运的是,对我来说,性能影响还不够大,不需要更改应用程序。

如果您可以在插入时不使用binary_ci,那么我会在插入之前和之后进行更改会话,这样您就不必删除触发器

I found the same performance issue with inserts and nls in 11g r2! Luckily for me the performance hit was not significant enough requiring an app change.

If you can do without binary_ci for the INSERT, then I would do an alter session just before the insert and afterwards, so you don't have to drop the trigger

~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文