学习是一种信仰。
分类: Oracle
2013-03-28 15:18:28
今天往oracle insert中文日期(16-1月 -13)时报错:ora-01843,无效的月份;
Cause:A date specified an invalid month. Valid months are: January-December, for format code MONTH, and Jan-Dec, for format code MON.
Action:Enter a valid month value in the correct format.
1、查看客户端字符集:
SQL> select sysdate from dual;
SYSDATE
------------
25-MAR-13
----说明客户端字符集为英文;
2、查看参数nls_date_language:
SQL> show parameter nls_date_language;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
nls_date_language string
没有设置,是默认值,参看文档:
说明,默认值从NLS_LANGUAGE继承:
SQL> show parameter nls_language;
NAME TYPE
------------------------------------ ----------------------
VALUE
------------------------------
nls_language string
AMERICAN
查询该会话该参数的值:
SQL> select * from nls_session_parameters where parameter='NLS_DATE_LANGUAGE';
PARAMETER
------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
NLS_DATE_LANGUAGE
AMERICAN
3、修改字符集
修改客户端字符集:
E:\>set NLS_LANG=AMERICAN_AMERICA.ZHS16GBK
SQL> select sysdate from dual;
SYSDATE
--------------
25-3? -13
修改会话字符集:
SQL> alter session set nls_date_language='SIMPLIFIED CHINESE';
Session altered.
SQL> select * from nls_session_parameters where parameter='NLS_DATE_LANGUAGE';
PARAMETER
------------------------------------------------------------
VALUE
--------------------------------------------------------------------------------
NLS_DATE_LANGUAGE
SIMPLIFIED CHINESE