mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-12-19 21:03:51 +00:00
8623cb232c
* CLICKHOUSE-4063: less manual html @ index.md * CLICKHOUSE-4063: recommend markdown="1" in README.md * CLICKHOUSE-4003: manually purge custom.css for now * CLICKHOUSE-4064: expand <details> before any print (including to pdf) * CLICKHOUSE-3927: rearrange interfaces/formats.md a bit * CLICKHOUSE-3306: add few http headers * Remove copy-paste introduced in #3392 * Hopefully better chinese fonts #3392 * get rid of tabs @ custom.css * Apply comments and patch from #3384 * Add jdbc.md to ToC and some translation, though it still looks badly incomplete * minor punctuation * Add some backlinks to official website from mirrors that just blindly take markdown sources * Do not make fonts extra light * find . -name '*.md' -type f | xargs -I{} perl -pi -e 's//g' {} * find . -name '*.md' -type f | xargs -I{} perl -pi -e 's/ sql/g' {} * Remove outdated stuff from roadmap.md * Not so light font on front page too * Refactor Chinese formats.md to match recent changes in other languages
50 lines
1.6 KiB
Markdown
50 lines
1.6 KiB
Markdown
<a name="table_functions-file"></a>
|
||
|
||
# file
|
||
|
||
Создаёт таблицу из файла.
|
||
|
||
```
|
||
file(path, format, structure)
|
||
```
|
||
|
||
**Входные параметры**
|
||
|
||
- `path` — относительный путь до файла от [user_files_path](../../operations/server_settings/settings.md#user_files_path).
|
||
- `format` — [формат](../../interfaces/formats.md#formats) файла.
|
||
- `structure` — структура таблицы. Формат `'colunmn1_name column1_ype, column2_name column2_type, ...'`.
|
||
|
||
**Возвращаемое значение**
|
||
|
||
Таблица с указанной структурой, предназначенная для чтения или записи данных в указанном файле.
|
||
|
||
**Пример**
|
||
|
||
Настройка `user_files_path` и содержимое файла `test.csv`:
|
||
|
||
```bash
|
||
$ grep user_files_path /etc/clickhouse-server/config.xml
|
||
<user_files_path>/var/lib/clickhouse/user_files/</user_files_path>
|
||
|
||
$ cat /var/lib/clickhouse/user_files/test.csv
|
||
1,2,3
|
||
3,2,1
|
||
78,43,45
|
||
```
|
||
|
||
Таблица из `test.csv` и выборка первых двух строк из неё:
|
||
|
||
``` sql
|
||
SELECT *
|
||
FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32')
|
||
LIMIT 2
|
||
```
|
||
```
|
||
┌─column1─┬─column2─┬─column3─┐
|
||
│ 1 │ 2 │ 3 │
|
||
│ 3 │ 2 │ 1 │
|
||
└─────────┴─────────┴─────────┘
|
||
```
|
||
|
||
[Оригинальная статья](https://clickhouse.yandex/docs/ru/query_language/table_functions/file/) <!--hide-->
|