Showing posts with label globalization settings. Show all posts
Showing posts with label globalization settings. Show all posts

Sunday, May 13, 2007

Time zones

To get time zone of the database:
select DBTIMEZONE from dual;
To get your session time zone:
select SESSIONTIMEZONE from dual;
To change database time zone (instance restart is needed):
alter database set time_zone='Europe/Tallinn'; --or '+02:00'
To change session time zone:
alter session set time_zone='Europe/Tallinn';
To get the list of all time zone names:
select * from v$timezone_names;

Case insensitive operations in 10g

to get a linguistic sorts, set the NLS_SORT session parameter to the desired linguistic rule set.
eg. alter session set nls_sort=ESTONIAN

add a "_CI" to get case insensitive or "_AI" to get both case and accent insensitive sorting

or use the NLSSORT function

select name from empliyees order by NLSSSORT(name,'NLS_SORT=ESTONIAN_AI');

to perform case insensitive comparisons set the NLS_COMP parameter to 'LINGUISTIC'. This will make the WHERE clause conditions use the rules set by the NLS_SORT parameter

Like this:
alter session set NLS_COMP=LINGUISTIC;
alter session set NLS_SORT=ESTONIAN_CI;
select name from employees where name like 'SomEnAme';

To achive same results without setting the NLS_SORT, NLSSORT function could be used like this:
select * from scott.l where nlssort(name,'nls_sort=BINARY_AI') like nlssort('koger', 'nls_sort=BINARY_AI');

Globalization settings

Views holding the NLS parameters.
In ascending order of priority:

select * from nls_database_parameters;
select * from nls_instance_parameters;


To get your currently active settings:
select * from nls_session_parameters;
or a more complete version: v$nls_parameters