首页
学习
活动
专区
圈层
工具
发布
社区首页 >专栏 >【YashanDB 知识库】导入数据时报错:YAS-00008 type convert error:literal does not match format

【YashanDB 知识库】导入数据时报错:YAS-00008 type convert error:literal does not match format

作者头像
用户10349277
修改2025-02-28 09:20:13
修改2025-02-28 09:20:13
2130
举报

现象

将数据通过 SQL 语气导入崖山时报错:YAS-00008 type convert error : literal does not match format string

原因

插入日期类型的字符串,不是配置参数 DATE_FORMAT 所指定的配置参数。数据库的默认 DATE_FORMAT=’yyy-mm-dd', 如果插入的期类型的字符串是 '2024-12-16 11:27:03' 就会报该错误。 例如:

CREATE TABLE test (f date); -- 导入的表中有 date 字段

insert into test (f) values ('2024-12-16 11:27:03'); -- 导入数据的日期类型的字符串

就会的报错 “literal does not match format string”, 可以认为是插入时数据库 DATE_FORMAT 格式进行 to_date 转换时报错形如: SELECT to_date ('2024-12-16 11:27:03', 'yyyy-mm-dd') FROM dual;

也会报一样的错误。

解决办法

1、修改配置参数 DATE_FORMAT 为导入的时间格式,'2024-12-16 11:27:03' 就用 'yyyy-mm-dd hh24:mi:ss'

alter system set DATE_FORMAT='yyyy-mm-dd hh24:mi:ss' scope=spfile; -- 修改后,需要重启数据库参数才生效

2、不修改配置参数 DATE_FORMAT,特定语句指定转换格式如:

insert into test values(to_date('2024-12-16 11:27:03', 'yyyy-mm-dd hh24:mi:ss'));

本文系转载,前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文系转载前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档