mysql数据表逐字段load对应文件,操作方法?
萝呆子 2018-02-24 12:26:14 现有三个csv文件,每个均有 1列、10行数据,数据表test有三个字段,对应这三个csv文件,想要逐个导入这些文件至数据表中,怎么写dos命令?(暂时只考虑如何命令实现,不考虑合并csv再导入等其它方法)
我写的这些命令执行结束后,数据表为30行,第一列后面20行为null,第二列两头20行为null,第三列前20行为null。
create table test (name varchar(82));
load data local infile 'e:\\a1.csv' into table test fields terminated by ',' enclosed by '"'(`name`);
alter table test add sex varchar(82);
load data local infile 'e:\\a2.csv' into table test fields terminated by ',' enclosed by '"'(`sex`);
alter table test add id varchar(82);
load data local infile 'e:\\a3.csv' into table test fields terminated by ',' enclosed by '"'(`id`);