I have a small problem with MariaDB:
I have a table with several columns, one of which is called fecha_hora
. When trying to insert data with load data infile
, MariaDB tells me that it does not recognize this column. I deleted and created the table several times, and yet I still see the same error.
The code I am running is the following:
drop table if exists mi_tabla
create table mi_tabla (
id int unsigned not null auto_increment primary key,
nombre_archivo varchar(255),
res varchar(100),
tipo varchar(10),
fecha_hora datetime,
unidades int unsigned,
fecha date,
hora date,
);
-- La tabla se crea correctamente
delimiter $$
create or replace trigger trig_mi_tabla_bi before insert on mi_tabla
for each row
begin
set new.fecha = date(fecha_hora);
set new.hora = time(fecha_hora);
end $$
delimiter ;
-- La creación del trigger no muestra errores
load data infile 'c:/ruta/a/mi/archivo/mi_archivo.csv'
into table mi_tabla
fields terminated by ',' optionally enclosed by '"'
lines terminated by '\r\n' ignore 1 lines
(res, tipo, fecha_hora, unidades);
-- Aquí es donde aparece el error:
-- ERROR 1054 (42S22): Unknown column 'fecha_hora' in 'field list'
As far as I can see, there is nothing wrong written ...
Here is a sample of the file that I am uploading:
Res,Tipo,Fecha,Unid
res0010,VX,2016-10-07 21:29:56,8
res0010,VX,2016-10-07 21:38:01,60
res0010,VX,2016-10-07 22:30:30,60
res0010,VY,2016-10-09 17:05:56,60
res0010,DD,2016-10-10 08:52:17,159212
res0010,DD,2016-10-10 08:53:37,7465