在文件名与表名不同的情况下使用 mysqlimport
我一直在使用 mysqlimport 并且遇到了文件名必须与表名相同的限制。有什么办法可以解决这个问题吗?
我无法重命名该文件,因为它被其他进程使用,并且我不想复制该文件,因为其中会有很多文件,其中一些非常大。
我想使用 mysqlimport 而不是 LOAD INFILE。
编辑:不幸的是,这需要在 Windows 上运行,所以恐怕没有符号链接的技巧。
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 there 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.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
你没说你在什么平台。在 unix 上,您可以创建到该文件的符号链接:
然后在 mysqlimport 命令中使用它。
但 mysqlimport 只是 LOAD INFILE 的命令行界面,因此您也可以在命令行上执行此操作:
You didn't say what platform you are on. On unix you can create a symbolic link to the file:
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:
mysqlimport 使用文件名来确定应将数据加载到的表的名称。该程序通过剥离任何文件扩展名(最后一个句点及其后面的任何内容)来实现此目的;然后将结果用作表名。例如,mysqlimport 将名为 City.txt 或 City.dat 的文件视为要加载到名为 City 的表中的输入。
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.
假设您使用的是 Linux 系统,您是否尝试过使用
alias
命令?Have you tried using the
alias
command, assuming you are on a Linux system?只需创建一个符号链接:
Just create a symbolic link: