Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

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

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?

like image 951
Alex Larzelere Avatar asked Dec 28 '22 09:12

Alex Larzelere


1 Answers

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.

like image 135
APC Avatar answered Apr 05 '23 23:04

APC