The function in MySQL that reads file content is LOAD_FILE(), and the usage is LOAD_FILE(file_name), where file_name is the file path and name. The function returns a string of file content, such as: SELECT LOAD_FILE('/tmp/data.txt'). However, attention should be paid to file system permissions, path correctness, large file reading time, and returning NULL if the file does not exist.
Which MySQL function can read the file contents?
The function in MySQL that can read the contents of the file is LOAD_FILE()
.
Function usage
<code class="sql">LOAD_FILE(file_name)</code>
Parameters
file_name
: The path and name of the file to be read. Return value
Returns the string of the file content.
Example
The following query reads the contents from the /tmp/data.txt
file:
<code class="sql">SELECT LOAD_FILE('/tmp/data.txt');</code>
Note
LOAD_FILE()
The function may be affected by file system permissions and security settings. NULL
. The above is the detailed content of Which function in mysql can read file content. For more information, please follow other related articles on the PHP Chinese website!