I'm reading a history in a txt (there are 6 million records, that's why I only show a part)
This way it is loaded in a table but I am interested in having the oldest date with its corresponding values ( estatus
, token
, sucursal
and fecha
)
solve it using a replace
but it is very slow since it writes several times the record until the last one
A way to tell loadata
to start reading the file from the end and thus be able to use a ignore
and make the load faster? I leave the code I use to load my table
LOAD DATA INFILE 'C:/BDS/OPER_NOT_SOFTTKN_20180508.txt'
replace
INTO TABLE supertoken
FIELDS TERMINATED BY ','
LINES TERMINATED BY '\n'
IGNORE 1 LINES
(
num_bug,
@estatus_token,
@dummy,
@fecha,
@dummy,
@dummy,
sucursal,
supertoken_id,
@dummy
)
set estatus_token=
case
WHEN LENGTH(@estatus_token)=6 THEN 1
WHEN LENGTH(@estatus_token)=8 THEN 1
WHEN LENGTH(@estatus_token)=18 THEN 3
WHEN LENGTH(@estatus_token)=16 THEN 4
WHEN LENGTH(@estatus_token)=14 THEN 5
WHEN LENGTH(@estatus_token)=9 THEN 6
else 99
END,
fecha=STR_TO_DATE(@fecha,'%d/%m/%Y %H:%i:%s'),
tipo_token=
case
WHEN tipo_token THEN 1
else 1
end;