Site icon BASIS GURU

How To Set NLS_DATE_FORMAT Parameter In Oracle

www.basisguru.com

NLS_DATE_FORMAT is one of the initialization parameter in Oracle.

What are The Initialization parameter in Oracle?

Initialization parameter in oracle defines the behavior of the database.
From DBA perspective, these parameters can be used to improve the performance of the database.

Today we will focus on the parameter: NLS_DATE_FORMAT

For e.g.:

NLS_DATE_FORMAT = "MM/DD/YYYY"

Parameter in oracle NLS_TERRITORY defines the Default value of this parameter.

PropertyDescription
Parameter typeString
Parameter scopeInitialization parameter, environment variable, and ALTER SESSION
Default valueDerived from NLS_TERRITORY
Range of valuesAny valid date format mask

Get the default value of parameter NLS_DATE_FORMAT.

We can find the default value of parameter NLS_DATE_FORMAT by executing below query:

SELECT * FROM v$nls_parameters WHERE parameter ='NLS_DATE_FORMAT';

Query will displayed output as:

NLS_DATE_FORMAT = "MM/DD/YYYY"

Set the value of parameter: NLS_DATE_FORMAT.

We can use below query to change the value of the parameter for a specific session:

ALTER SESSION SET NLS_DATE_FORMAT = 'YYYY-MM-DD HH24:MI:SS';

NOTE:
Once this session is killed, the value of the set parameter will no longer be valid.
It will be overwritten by the Default value or by the client-side value .

References:
https://docs.oracle.com/

Exit mobile version