Oracle sql loader 日期格式问题

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/5235534/
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-18 22:57:51  来源:igfitidea点击:

Oracle sql loader date format issue

sqloracledate

提问by Amr H. Abd Elmajeed

I'm new to sql loader, and i'm having a problem with the date format.

我是 sql loader 的新手,我的日期格式有问题。

Here is the input file record sample:

这是输入文件记录示例:

Y,1525039510,http-192.168.2.2,15-01-2011 00:00:032:728,64
Y,1525131958,http-192.168.2.2,15-01-2011 00:00:033:613,75

Y,1525039510,http-192.168.2.2,15-01-2011 00:00:032:728,64
Y,1525131958,http-192.168.2.2,15-01-2011:00:375603

I'm having a problem with the fourth column, the date.

我对第四列(日期)有疑问。

My current field entry is this:

我当前的字段条目是这样的:

start_time DATE "DD-MM-YYYY HH:MI

start_time DATE "DD-MM-YYYY HH:MI

How do i parse the last part of the input 032:728 (seconds and milliseconds)

我如何解析输入的最后一部分 032:728(秒和毫秒)

I tried SSS:FF3 and SS.FF3, no luck.

我试过 SSS:FF3 和 SS.FF3,没有运气。

回答by Vincent Malgrat

You could treat the input as a string and transform it with a function. Something like this should work:

您可以将输入视为字符串并使用函数对其进行转换。这样的事情应该工作:

start_time CHAR to_date(substr(:start_time, 1, 20), 'dd-mm-yyyy hh24:mi":0"ss')

I had to drop the millisecond part since they are not part of the DATE datatype (to_datedoesn't recognize the FFformat).

我不得不删除毫秒部分,因为它们不是 DATE 数据类型的一部分(to_date不识别FF格式)。

回答by ik_zelf

You can read this into a timestamp field. The data looks a bit weird: 15-01-2011 00:00:033:613,75 but the conversion format should be dd-mm-yyyy hh[24]:mi:0ss:fff,ff Make sure that your nls settings are as expected.

您可以将其读入时间戳字段。数据看起来有点奇怪:15-01-2011 00:00:033:613,75 但转换格式应该是 dd-mm-yyyy hh[24]:mi:0ss:fff,ff 请确保您的 nls 设置符合预期。

Ronald.

罗纳德。