如下的语句:
?select to_date('2003,May-22','YYYY,Mon-dd') from dual;
遇到ORA-01843:not a valid month的错误,根据搜索,知道是nls_date_language这个参数引起的问题,在nls_date_language参数设置为 AMERICAN的时候,是可以显示英文月份的,所以查看nls_date_language这个参数:
SQL> show parameter nls_date_language;
NAME???????????????????????????????? TYPE??????? VALUE
------------------------------------ ----------- ------------------------------
nls_date_language??????????????????? string
没有设置,是默认值,参看文档:
Parameter type | String |
Syntax |
NLS_DATE_LANGUAGE = ?language
|
Default value | Derived from?NLS_LANGUAGE
|
Modifiable | ALTER SESSION |
Range of values | Any valid?NLS_LANGUAGE ?value |
默认值从NLS_LANGUAGE继承,而NLS_LANGUAGE为AMERICAN:
SQL>? show parameter nls_language;
NAME???????????????????????????????? TYPE??????? VALUE
------------------------------------ ----------- ------------------------------
nls_language???????????????????????? string????? AMERICAN
那为什么不能识别英文月份呢?
再查看会话级的参数:
SQL> run
? 1* select * from nls_session_parameters where parameter='NLS_DATE_LANGUAGE'
PARAMETER????????? VALUE
------------------ ------------------
NLS_DATE_LANGUAGE? SIMPLIFIED CHINESE
会话级的NLS_DATE_LANGUAGE设置为简体中文
所以解决此问题的方法也很简单,只要在会话前指定会话的NLS_DATE_LANGUAGE参数即可:
SQL> alter session set nls_date_language='AMERICAN';