Where can I query the current case-sensitivity setting of an oracle database?
I've tried looking in v$database
, nls_database_parameters
, and looking through the system packages, but none of them seem to provide the information I need...
Where can I query the current case-sensitivity setting of an oracle database?
I've tried looking in v$database
, nls_database_parameters
, and looking through the system packages, but none of them seem to provide the information I need...
在Oracle 10gR2
:
SELECT *
FROM NLS_SESSION_PARAMETERS
WHERE parameter IN ('NLS_COMP', 'NLS_SORT')
SQL> ALTER SESSION SET NLS_COMP = 'LINGUISTIC'
2 /
Session altered
SQL> SELECT COUNT(*)
2 FROM dual
3 WHERE 'a' = 'A'
4 /
COUNT(*)
----------
1
SQL> ALTER SESSION SET NLS_COMP = 'BINARY'
2 /
Session altered
SQL> SELECT COUNT(*)
2 FROM dual
3 WHERE 'a' = 'A'
4 /
COUNT(*)
----------
0
从文档:
NLS_COMP
指定数据库会话的整理行为。价值观:
BINARY
通常,
WHERE
子句和PL/SQL
块中的比较是二进制的,除非您指定NLSSORT
函数。
LINGUISTIC
子句和块中所有
SQL
操作的比较应使用参数中指定的语言排序。为了提高性能,您还可以在要进行语言比较的列上定义语言索引。WHERE
PL/SQL
NLS_SORT
ANSI
设置
ANSI
是为了向后兼容;一般来说,你应该设置NLS_COMP
为LINGUISTIC
除了已经给出的答案之外,请注意 11g 中区分大小写的变化 - 例如,请参阅 11g 文档重新密码。
对于 Oracle 10gR2(及更高版本),参数为 NLS_COMP 和 NLS_SORT。
select * from v$nls_parameters where parameter in ('NLS_COMP','NLS_SORT');
(这些参数在会话级别设置。会话的设置继承自数据库设置,除非通过设置 OS 环境变量或 ALTER SESSION 语句覆盖。)
如果您想要“不区分大小写”的排序和字符串匹配,您可以尝试以下设置:
alter session set NLS_SORT=BINARY_CI;
alter session set NLS_COMP=LINGUISTIC;
当然,这些不是参数的唯一设置。Oracle 10gR2 文档: