MySQL:将多个文件加载到表中
我一直试图将多个文件加载到一个表中,以便它们适合同一行.
I've been trying to load multiple files into a table, so that they would fit the same row.
我可以分别插入它们,但是问题出在NULL
值之内,因此我打算加入该表.如果发生这种情况,我会得到太多的NULL
值-无用的数据.
I can insert them separately, but then the issue lies within the NULL
values, and I plan to JOIN this table. If that happens, I get too many NULL
values -- useless data.
LOAD DATA LOCAL INFILE 'malefirst.txt, femalefirst.txt, allfirst.txt, allfirst.txt'
INTO TABLE fnames
(mal, fml, unk, cpx);
我实际上研究过的另一件事是将文件与
Another thing I have actually looked into was joining the files together with
paste -d " " (1.txt 2.txt ....)
但是,它变成了一团糟.如果第一种方法不起作用,那么我可以使用第二种方法,但是我也需要有关它的建议.
However, it turned into a mess. If the first method does not work, then I can use the second, but I will need advice on it as well.
您可以将4个文件加载到4个(临时)表中(每个表都有一个自动编号的字段),然后将这些文件加入(使用ID)到表中.
You could load the 4 files into 4 (temporary) tables (each with an autonumbered field) and then JOIN (using the ids) these files INTO your TABLE.