首页 诗词 字典 板报 句子 名言 友答 励志 学校 网站地图
当前位置: 首页 > 教程频道 > 数据库 > oracle >

ORA-01843: not a valid month

2014-01-28 
insert into authors(author_id,first_name,last_name,birthdate,gender,nationality_id,phone)values(25,

insert into authors(author_id,first_name,last_name,birthdate,gender,nationality_id,phone)values(25,'David','Sell',to_date('14-JUN-2005','DD-MON-YYYY'),'M','12','01-8928-9207')

ORA-01843: not a valid month

报什么错误啊?
格式“DD-MM-YYYY'的可以add,但是'DD-MON-YYYY'就报错,怎么解决?

------解决方法--------------------------------------------------------
insert into authors(author_id,first_name,last_name,birthdate,gender,nationality_id,phone)
values(26,'David','Sell',to_date('14-05-2008','DD-MM-YYYY'),'M','12','01-8928-9207');

试下吧 。

你要的是'DD-MON-YYYY'是不是 纯英文系统才可以有的字符串呢 ?这个我不敢确定,只是疑惑啦!
------解决方法--------------------------------------------------------
我查到了 :

中文系统下:
insert into authors(author_id,first_name,last_name,birthdate,gender,nationality_id,phone)
values(27,'David','Sell',to_date('14-6月-2008','DD-MON-YYYY'),'M','12','01-8928-9207');

英文系统下:
insert into authors(author_id,first_name,last_name,birthdate,gender,nationality_id,phone)
values(27,'David','Sell',to_date('14-JAN-2008','DD-MON-YYYY'),'M','12','01-8928-9207');

------解决方法--------------------------------------------------------
我猜你的操作系统是中文的。
------解决方法--------------------------------------------------------
是的,和操作系统的语言有关
------解决方法--------------------------------------------------------
 

SQL code
insert into authors(author_id,first_name,last_name,birthdate,gender,nationality_id,phone) values(27,'David','Sell',to_date('14-6月-2008','DD-MON-YYYY'),'M','12','01-8928-9207');
------解决方法--------------------------------------------------------
是操作系统的原因吧,在中文和英文系统下,日期的显示格式是不同的

------解决方法--------------------------------------------------------
可以用
alter session set nls_date_format = 'xxxxxxxx'
修改日期格式
------解决方法--------------------------------------------------------
the answer is:
alter session set nls_date_language='american';
insert into authors(author_id,first_name,last_name,birthdate,gender,nationality_id,phone)values(25,'David','Sell',to_date('14-JUN-2005','DD-MON-YYYY'),'M','12','01-8928-9207')

------解决方法--------------------------------------------------------