SELECT INTO DUMPFILE

While learning a new ORDER BY syntax recently, as a diligent architect/DBA I reviewed the documentation. What I also found in the SELECT syntax which I did not also know was the keyword DUMPFILE.

The SELECT Syntax from MySQL 5.1 Manual states:

If you use INTO DUMPFILE instead of INTO OUTFILE, MySQL writes only one row into the file, without any column or line termination and without performing any escape processing. This is useful if you want to store a BLOB value in a file.

It’s a shame there is no middle ground, where you get the features of OUTFILE (i.e. all rows), and the features of DUMPFILE (i.e. no heading)

Comments

  1. says

    The purpose of the INTO DUMPFILE sintax is to write a blob to a file.

    To avoid the heading, simulating the INTO DUMPFILE effect, you can use the command line:
    mysql -N -B -e “select column_name from table_name” > myfile

    Giuseppe