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...
In 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
From documentation:
NLS_COMPspecifies the collation behavior of the database session.Values:
BINARYNormally, comparisons in the
WHEREclause and inPL/SQLblocks is binary unless you specify theNLSSORTfunction.
LINGUISTICComparisons for all
SQLoperations in theWHEREclause and inPL/SQLblocks should use the linguistic sort specified in theNLS_SORTparameter. To improve the performance, you can also define a linguistic index on the column for which you want linguistic comparisons.
ANSIA setting of
ANSIis for backwards compatibility; in general, you should setNLS_COMPtoLINGUISTIC
For Oracle 10gR2 (and later), the parameters are NLS_COMP and NLS_SORT.
select * from v$nls_parameters where parameter in ('NLS_COMP','NLS_SORT');
(These parameters are set at the session level. The settings for a session are inherited from the database setting, unless overridden by setting an OS environment variable, or an ALTER SESSION statement.)
If you want "case-insensitive" sorting and string matching, you can try these settings:
alter session set NLS_SORT=BINARY_CI;
alter session set NLS_COMP=LINGUISTIC;
Those aren't the only settings for the parameters, of course. Oracle 10gR2 documentation: