如何使用Oracle Sql Loader使用当前时间戳填充时间戳字段 [英] How to populate a timestamp field with current timestamp using Oracle Sql Loader

查看:219
本文介绍了如何使用Oracle Sql Loader使用当前时间戳填充时间戳字段的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在使用SQL Loader读取管道定界文件,并希望在要填充的表中填充LAST_UPDATED字段.我的控制文件如下:

I'm reading a pipe delimited file with SQL Loader and want to populate a LAST_UPDATED field in the table I am populating. My Control File looks like this:

LOAD DATA
INFILE SampleFile.dat
REPLACE
INTO TABLE contact
FIELDS TERMINATED BY '|'
OPTIONALLY ENCLOSED BY '"'
(
ID, 
FIRST_NAME,
LAST_NAME,
EMAIL,
DEPARTMENT_ID,
LAST_UPDATED SYSTIMESTAMP
)

对于LAST_UPDATED字段,我尝试了SYSTIMESTAMP和CURRENT_TIMESTAMP,但都不起作用.但是,SYSDATE可以正常工作,但没有给我一天的时间.

For the LAST_UPDATED field I've tried SYSTIMESTAMP and CURRENT_TIMESTAMP and neither work. SYSDATE however works fine but doesn't give me the time of day.

我是SQL Loader的新手,所以我对它的功能或功能不了解甚少.谢谢.

I am brand new to SQL Loader so I really know very little about what it is or isn't capable of. Thanks.

推荐答案

您是否尝试过以下方法:

Have you tried the following:

CURRENT_TIMESTAMP [(精度)]

CURRENT_TIMESTAMP [ (precision) ]


select current_timestamp(3) from dual;

CURRENT_TIMESTAMP(3)
-----------------------------
10-JUL-04 19.11.12.686 +01:00

要在SQLLDR中执行此操作,您将需要在CTL文件中使用EXPRESSION,以便SQLLDR知道将调用视为SQL.

To do this in SQLLDR, you will need to use EXPRESSION in the CTL file so that SQLLDR knows to treat the call as SQL.

替换:


LAST_UPDATED SYSTIMESTAMP

具有:


LAST_UPDATED EXPRESSION "current_timestamp(3)"

这篇关于如何使用Oracle Sql Loader使用当前时间戳填充时间戳字段的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆