I know there’s the LOAD DATA INFILE statement, which allows me to INSERT structured data into a table.
What I’m curious about, is whether it is possible to INSERT contents of a file into single column. So, is something like this:
INSERT INTO my_table (stamp, what) VALUES (NOW(), LOAD DATA INFILE 'my_file');
possible?
Yes it’s possible. You can use the
LOAD_FILE()function:You’ll have to make sure that the file is readable by MySQL, and that your MySQL user has the
FILEprivilege. This is the same privilege required forLOAD DATA INFILE.