将 YYYY-MM-DDTHH24:MI:SEC.milliseconds 时间戳插入 Oracle

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/37618644/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-19 03:14:56  来源:igfitidea点击:

Insert YYYY-MM-DDTHH24:MI:SEC.milliseconds timestamp to Oracle

oracleplsqlsqlplus

提问by Mendes

I need to insert the following date/time format to Oracle:

我需要向 Oracle 插入以下日期/时间格式:

INSERT INTO mytable (ID, DATETIMEREAD) VALUES (1, TO_TIMESTAMP('2016-06-03T11:28:07.571', 'YYYY-MM-DDTHH24:MM:SS')

I′m getting the following error:

我收到以下错误:

ORA-01821: date format not recognized

How can I properly insert that ISO format (without time zone) to Oracle. The DATETIMEREADcolumn type is TIMESTAMP(6)

如何将 ISO 格式(不带时区)正确插入到 Oracle。该DATETIMEREAD列类型是TIMESTAMP(6)

回答by Husqvik

Tis not any Oracle timestamp element. You need to enclose it in double quotes. Also minutes are MIand you miss the fraction of second mask too. This should do the job:

T不是任何 Oracle 时间戳元素。您需要将其括在双引号中。还有几分钟MI,你也错过了第二个面具的分数。这应该可以完成这项工作:

INSERT INTO mytable (ID, DATETIMEREAD) VALUES (1, TO_TIMESTAMP('2016-06-03T11:28:07.571', 'YYYY-MM-DD"T"HH24:MI:SS.FF3'))