I’v read that DATE format is controlled by NLS_DATE_FORMAT setting defined at global scope (nls_database_parameters) or at session scope (nls_session_parameters). However, I’m able to insert DATE value of the format ‘YYYY.MM.DD’. Here’s an insert:
INSERT INTO people (id, name, surname, birth) VALUES (11, 'John', 'Johny', '1979.02.23')
Here are settings from nls_database_parameters:
NLS_TERRITORY = AMERICA
NLS_DATE_FORMAT = DD-MON-RR
NLS_DATE_LANGUAGE = AMERICAN
Here are the settings from nls_session_parameters:
NLS_TERRITORY = CANADA
NLS_DATE_FORMAT = RR-MM-DD
NLS_DATE_LANGUAGE = ENGLISH
As supossed, birth values appears as ‘YY.MM.DD’ when selecting, so nls_session_parameters take priority. NSL_SESSION_Parameters are related to the settings used in Windows XP Regional and language settings. However, not sure why Oracle is not complaining when I do inserting with ‘YYYY.MM.DD’?
UPDATE: It appears NLS_DATE_FORMAT was implicitly set to ‘RR.MM.DD’ (not YY.MM.DD), and RR year format allows to insert full year. If year value is presented in RR format then Oracle rounds to a year in the range 1950 to 2049. Thus, 06 is considered 2006 instead of 1906. Also, thanks to comprehensive paulsm4 referenced article.
The NLS_DATE_FORMAT you set in your init.ora, or even in your session, can be overridden by other factors. Here’s a good link that gives more details: