开发者

Using mysqlimport where the filename is different from the table name

开发者 https://www.devze.com 2022-12-24 17:35 出处:网络
I\'ve been playing with mysqlimport and I\'ve run into the restriction where the filename has to be the same as the table name.Is t开发者_如何学JAVAhere any way to work round this?

I've been playing with mysqlimport and I've run into the restriction where the filename has to be the same as the table name. Is t开发者_如何学JAVAhere any way to work round this?

I can't rename the file as it is used by other processes and I don't want to copy the file as there will be many of them, some being very large.

I want to use mysqlimport not LOAD INFILE.

EDIT: Unfortunately this needs to run on windows so no tricks with symbolic links I'm afraid.


You didn't say what platform you are on. On unix you can create a symbolic link to the file:

ln -s filename.txt tablename.txt

Then use that in the mysqlimport command.

But mysqlimport is just a command line interface to LOAD INFILE so you could also do this on the command line:

mysql -e "load data infile 'filename' into table TBL_NAME" dbname


mysqlimport uses the filename to determine the name of the table into which the data should be loaded. The program does this by stripping off any filename extension (the last period and anything following it); the result is then used as the table name. For example, mysqlimport treats a file named City.txt or City.dat as input to be loaded into a table named City.


Have you tried using the alias command, assuming you are on a Linux system?


Just create a symbolic link:

ln -s /tmp/real_file.txt /tmp/your_table_name.txt
0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号