Writing a BLOB to a File


SELECT data FROM some_table   WHERE name="img12"   INTO DUMPFILE "/tmp/img12.jpg"; 



If you have stored binary data from a file in a BLOB column within a table and want to reconstitute it into a file, use the INTO DUMPFILE clause of the SELECT statement. INTO DUMPFILE writes data from a query directly to a file without modifying it in any way.

INTO DUMPFILE only works with SELECT statements that return a single row. If multiple columns are in the row, they are concatenated together without any separator. For example,

SELECT 1, 2, 3, 4 INTO DUMPFILE '/tmp/numbers'; 


creates a file that contains 1234.



MySQL Phrasebook. Essential Code and Commands
MySQL Phrasebook
ISBN: 0672328399
EAN: 2147483647
Year: 2003
Pages: 130

Similar book on Amazon

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net