首页 > 技术文章 > sqlldr导入时间类型的字段

remote-antiquity 2017-09-25 15:08 原文

比方说一张表test

create table test(aa date);

 

然后控制文件可以有两种写法,

1:一种是以数据库中的默认时间格式写,

一般是DD-MON-YY的,

格式就是大概这种:控制文件中的字段列表就是这样:(aa )

数据文件就是这样:11-SEP-15

用的不是很爽,

2:这时就可以这样写:

load data
infile 'test.dat'
badfile 'test.bad'
discardfile 'test.dsc'
append
into table test
fields terminated by ',' trailing nullcols
(aa date "yyyy-mm-dd hh24:mi:ss")

 

或者也可以直接修改数据库的默认时间格式

 SQL> alter system set nls_date_format ='YYYY-MM-DD hh24:mi:ss' scope=spfile;

 

推荐阅读