Convert date from one format to another using SQL*Loader control file

Alex Larzelere picture Alex Larzelere · Jul 22, 2010 · Viewed 30k times · Source

The data from the infile is in the format MM/DD/YYYY how do I tell the control file to load it into the database as YYYYMM?

Answer

APC picture APC · Jul 22, 2010

When you specify the columns in the INFILE declare just identify the format the data is held in. Like this

load data
infile 'whatever.csv'
into table t23
fields terminated by ','
trailing nullcols
(
       col_1    integer 
     , col_2    char 
     , col_3    date "MM/DD/YYYY"
     , col_4    date "MM/DD/YYYY"
     , col_5    char 
)

Don't worry about the "to" date format. That is only for display purposes. Oracle stores dates in its own internal representation.