May 2005
Intermediate to advanced
352 pages
14h 39m
English
LOAD_FILE( )
LOAD_FILE(filename)This function reads the contents of a file. The user must have file privileges in MySQL, and the file must be readable by all users on the filesystem. It returns NULL if the file doesn't exist, if the user doesn't have proper permissions, or if the file is otherwise unreadable.
UPDATE applications
SET essay = LOAD_FILE('/tmp/smith_john.txt')
WHERE applicant_id = '7382';In this example, an essay written by someone who is applying for
admission to the university is loaded into the
essay column (which is a BLOB
datatype) of the row for the applicant in the
applications table. The entire contents of the
file, including any binary data such as hard returns and photographs,
are loaded from the file into the table.
Read now
Unlock full access