Preso dalla documentazione di MySql:
<BLOCKQUOTE id=quote><!--<font size= face="" id=quote>-->quote:<hr height=1 noshade id=quote>
The SELECT ... INTO OUTFILE 'file_name' form of SELECT writes the selected rows to a file. The file is created on the server host and cannot already exist (among other things, this prevents database tables and files such as `/etc/passwd' from being destroyed). You must have the FILE privilege on the server host to use this form of SELECT. The SELECT ... INTO OUTFILE statement is intended primarily to let you very quickly dump a table on the server machine. If you want to create the resulting file on some other host than the server host, you can't use SELECT ... INTO OUTFILE. In this case you should instead use some client program like mysqldump --tab or mysql -e "SELECT ..." > outfile to generate the file. SELECT ... INTO OUTFILE is the complement of LOAD DATA INFILE; the syntax for the export_options part of the statement consists of the same FIELDS and LINES clauses that are used with the LOAD DATA INFILE statement. See section 13.1.5 LOAD DATA INFILE Syntax. In the resulting text file, only the following characters are escaped by the ESCAPED BY character:
The ESCAPED BY character
The first character in FIELDS TERMINATED BY
The first character in LINES TERMINATED BY
Additionally, ASCII 0 is converted to ESCAPED BY followed by 0 (ASCII 48). The reason for the above is that you must escape any FIELDS TERMINATED BY, ESCAPED BY, or LINES TERMINATED BY characters to reliably be able to read the file back. ASCII 0 is escaped to make it easier to view with some pagers. As the resulting file doesn't have to conform to the SQL syntax, nothing else need be escaped. Here follows an example of getting a file in the format used by many old programs.
<pre id=code><font face=courier size= id=code>
SELECT a,b,a+b INTO OUTFILE "/tmp/result.text"
FIELDS TERMINATED BY ',' OPTIONALLY ENCLOSED BY '"'
LINES TERMINATED BY "\n"
FROM test_table;
</font id=code></pre id=code>
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote><!--</font id=quote><font face="" size= id=quote>-->
Spero ti possa essere utile
Alessandro
ICQ@Home # 47938486
ICQ@Work # 246829394 [ NOT AVAIABLE NOW ]