如何从追加SQL数据到现有文件 [英] How to append data from SQL to an existing file
问题描述
SQL有数据转储到一个文件的选项,使用INTO OUTFILE选项,〔实施例
SQL has the option to dump data into a file, using the INTO OUTFILE option, for exmaple
SELECT * from FIshReport INTO OUTFILE './FishyFile'
问题是,如果文件没有之前存在这个命令只允许执行。它创建的文件,然后输入数据。
那么,有没有什么办法可以这种方式将数据追加到一个文件?
The problem is, this command is only allowed if the file didn't exist before it. It creates the file and then enters the data. So, is there any way to append data to a file this way?
推荐答案
作为SELECT语法MySQL的页面提示:
As the MySQL page on SELECT syntax suggests:
http://dev.mysql.com/doc/refman/ 5.0 / EN / select.html
的替代品,这是发出SELECT从MySQL客户端:
the alternative to this is to issue the SELECT from the MySQL client:
However, if the MySQL client software is installed on the remote machine,
you can instead use a client command such as mysql -e "SELECT ..." > file_name
to generate the file on the client host.
其中,你的情况,将被修改为:
which, in your case, would be modified to be:
mysql -e "SELECT * from FishReport" >> file_name
让您只需追加到该文件。
so that you simply append to the file.
从你的Tcl脚本,你可以简单地发出此为exec命令:
From your Tcl script, you could simply issue this as an exec command:
http://www.tcl.tk/man/tcl/tutorial/ Tcl26.html
这篇关于如何从追加SQL数据到现有文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!