All pages
Powered by GitBook
1 of 1

Loading...

SELECT INTO DUMPFILE

Export a single row to a file without formatting. This statement writes raw binary data, such as BLOBs, directly to a file on the server.

Syntax

Description

SELECT ... INTO DUMPFILE is a clause which writes the resultset into a single unformatted row, without any separators, in a file. The results will not be returned to the client.

file_path can be an absolute path, or a relative path starting from the data directory. It can only be specified as a , not as a variable. However, the statement can be dynamically composed and executed as a prepared statement to work around this limitation.

This statement is binary-safe and so is particularly useful for writing values to file. It can be used, for example, to copy an image or an audio document from the database to a file.

The file must not exist. It cannot be overwritten. A user needs the privilege to run this statement. Also, MariaDB needs permission to write files in the specified location. If the system variable is set to a non-empty directory name, the file can only be written to that directory.

The system variable has controlled interpretation of file names that are given as literal strings.

The system variable does not have controlled interpretation of file names that are given as literal strings.

Example

See Also

This page is licensed: CC BY-SA / Gnu FDL

SELECT ... INTO DUMPFILE 'file_path'
SELECT
string literal
BLOB
FILE
secure_file_priv
character_set_filesystem
character_set_filesystem
SELECT
LOAD_FILE()
SELECT INTO Variable
SELECT INTO OUTFILE
SELECT _utf8'Hello world!' INTO DUMPFILE '/tmp/world';

SELECT LOAD_FILE('/tmp/world') AS world;
+--------------+
| world        |
+--------------+
| Hello world! |
+--------------+