在文件名与表名不同的情况下使用 mysqlimport

发布于 2024-08-26 01:14:58 字数 210 浏览 5 评论 0原文

我一直在使用 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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(4

情绪操控生活 2024-09-02 01:14:58

你没说你在什么平台。在 unix 上,您可以创建到该文件的符号链接:

ln -s filename.txt tablename.txt

然后在 mysqlimport 命令中使用它。

但 mysqlimport 只是 LOAD INFILE 的命令行界面,因此您也可以在命令行上执行此操作:

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

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
谜兔 2024-09-02 01:14:58

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.

や三分注定 2024-09-02 01:14:58

假设您使用的是 Linux 系统,您是否尝试过使用 alias 命令?

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

呆橘 2024-09-02 01:14:58

只需创建一个符号链接:

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

Just create a symbolic link:

ln -s /tmp/real_file.txt /tmp/your_table_name.txt
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文