mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-09-20 08:40:50 +00:00
CLICKHOUSEDOCS-508: Added question about how to export data to a file.
This commit is contained in:
parent
4d34c0ac43
commit
c228cffade
@ -21,4 +21,36 @@ If you use Oracle through the ODBC driver as a source of external dictionaries,
|
||||
NLS_LANG=RUSSIAN_RUSSIA.UTF8
|
||||
```
|
||||
|
||||
## How to export data from ClickHouse to the file?
|
||||
|
||||
### Using INTO OUTFILE Clause
|
||||
|
||||
Add [INTO OUTFILE](../query_language/select/#into-outfile-clause) clause to your query.
|
||||
|
||||
For example:
|
||||
|
||||
```sql
|
||||
SELECT * FROM table INTO OUTFILE 'file'
|
||||
```
|
||||
|
||||
By default, ClickHouse uses the [TabSeparated](../interfaces/formats.md#tabseparated) format for output data. To select the [data format](../interfaces/formats.md), use the [FORMAT clause](../query_language/select/#format-clause).
|
||||
|
||||
For example:
|
||||
|
||||
```sql
|
||||
SELECT * FROM table INTO OUTFILE 'file' FORMAT CSV
|
||||
```
|
||||
|
||||
### Using File-engine Table
|
||||
|
||||
See [File](../operations/table_engines/file.md).
|
||||
|
||||
### Using Command-line Redirection
|
||||
|
||||
```sql
|
||||
$ clickhouse-client --query "SELECT * from table" > result.txt
|
||||
```
|
||||
|
||||
See [clickhouse-client](../interfaces/cli.md).
|
||||
|
||||
[Original article](https://clickhouse.yandex/docs/en/faq/general/) <!--hide-->
|
||||
|
@ -1120,7 +1120,7 @@ The structure of results (the number and type of columns) must match for the que
|
||||
|
||||
Queries that are parts of UNION ALL can't be enclosed in brackets. ORDER BY and LIMIT are applied to separate queries, not to the final result. If you need to apply a conversion to the final result, you can put all the queries with UNION ALL in a subquery in the FROM clause.
|
||||
|
||||
### INTO OUTFILE Clause
|
||||
### INTO OUTFILE Clause {#into-outfile-clause}
|
||||
|
||||
Add the `INTO OUTFILE filename` clause (where filename is a string literal) to redirect query output to the specified file.
|
||||
In contrast to MySQL, the file is created on the client side. The query will fail if a file with the same filename already exists.
|
||||
@ -1128,7 +1128,7 @@ This functionality is available in the command-line client and clickhouse-local
|
||||
|
||||
The default output format is TabSeparated (the same as in the command-line client batch mode).
|
||||
|
||||
### FORMAT Clause
|
||||
### FORMAT Clause {#format-clause}
|
||||
|
||||
Specify 'FORMAT format' to get data in any specified format.
|
||||
You can use this for convenience, or for creating dumps.
|
||||
|
Loading…
Reference in New Issue
Block a user