ClickHouse/docs/en/sql-reference/functions/files.md

37 lines
1.2 KiB
Markdown
Raw Normal View History

---
sidebar_position: 43
sidebar_label: Files
---
2022-06-02 10:55:18 +00:00
# Functions for Working with Files
2022-06-02 10:55:18 +00:00
## file
Reads file as a String. The file content is not parsed, so any information is read as one string and placed into the specified column.
**Syntax**
``` sql
2022-07-14 09:49:30 +00:00
file(path[, default])
```
**Arguments**
- `path` — The relative path to the file from [user_files_path](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-user_files_path). Path to file support following wildcards: `*`, `?`, `{abc,def}` and `{N..M}` where `N`, `M` — numbers, `'abc', 'def'` — strings.
2022-07-14 09:49:30 +00:00
- `default` — The value that will be returned in the case when a file does not exist or cannot be accessed. Data types supported: [String](../../sql-reference/data-types/string.md) and [NULL](../../sql-reference/syntax.md#null-literal).
**Example**
Inserting data from files a.txt and b.txt into a table as strings:
Query:
``` sql
2021-03-28 18:26:51 +00:00
INSERT INTO table SELECT file('a.txt'), file('b.txt');
```
**See Also**
2021-03-26 08:22:43 +00:00
- [user_files_path](../../operations/server-configuration-parameters/settings.md#server_configuration_parameters-user_files_path)
2021-03-26 09:25:33 +00:00
- [file](../table-functions/file.md)