Methods of Setting NLS Parameters and their Priorities (Oracle Database)

Oracle Database includes a bunch of NLS (National Language Support) parameters that determine the locale-specific behaviour on both the client and the server.

These NLS parameters can be set in various places, each of which has a predetermined precedence order in relation to the others. The following table outlines these methods, as well as their priority in relation to the others.

PriorityMethod
1 (highest)Explicitly set in SQL functions.

Example:
TO_CHAR(SYSDATE, 'DD/MON/RR', 'nls_date_language = SPANISH')
2Set by an ALTER SESSION statement.

Example:
ALTER SESSION SET NLS_TERRITORY = 'AUSTRALIA';
3Set as an environment variable.

Example:
% setenv NLS_SORT FRENCH
4Specified in the initialization parameter file.

Example:
NLS_TERRITORY = "AMERICA"
5 (lowest)Default value specified when the database was created.

Just to be clear, higher priority settings override lower priority settings. So, setting an NLS parameter in a SQL function overrides all other places where that parameter has been set.

Not all functions allow for NLS parameters to be set at the function level. The ALTER SESSION statement is the next highest priority, and is therefore the quickest/easiest way to set an NLS parameter in such cases where the parameter is not hardcoded into the function.

For an example of setting NLS parameters at the session level, see How to Change the Date Format in your Oracle Session.

Checking the Values of the NLS Parameters

You can query the V$NLS_PARAMETERS dynamic performance view to check the current values of your current NLS parameters.

You can also check the session, instance, and database NLS parameters by querying the following data dictionary views:

  • NLS_SESSION_PARAMETERS shows the NLS parameters and their values for the session that is querying the view. It does not show information about the character set.
  • NLS_INSTANCE_PARAMETERS shows the current NLS instance parameters that have been explicitly set and the values of the NLS instance parameters.
  • NLS_DATABASE_PARAMETERS shows the values of the NLS parameters for the database. The values are stored in the database.

Also, user applications can query client NLS settings with the OCINlsGetInfo() function.

See How to Check the Values of the NLS Parameters for examples of checking NLS parameter values.