ClickHouse/docs/en/sql-reference/statements/select/into-outfile.md
2021-11-20 18:44:45 +00:00

1.3 KiB

toc_title
INTO OUTFILE

INTO OUTFILE Clause

INTO OUTFILE clause redirects the result of a SELECT query to a file on the client side. File compression is detected by the extension of the file name or it can be explicitly specified in a COMPRESSION clause.

Syntax

SELECT <expr_list> INTO OUTFILE filename [COMPRESSION type]

filename and type are string literals. Supported compression types are: 'gzip', 'deflate', 'br', 'xz', 'zstd', 'lz4', 'bz2'.

Implementation Details

Example

Execute a query in the command-line client:

clickhouse-client --query="SELECT 1,'ABC' INTO OUTFILE 'select.gz' FORMAT CSV;"
zcat select.gz 

Result:

1,"ABC"