mirror of
https://github.com/ClickHouse/ClickHouse.git
synced 2024-11-24 00:22:29 +00:00
06aa03f1a7
* Doc fixes: rm anchors <a> * Doc fixes: rm anchors <a> * Doc fixes: fix links * Doc fixes: fix the links
1.5 KiB
1.5 KiB
file
Creates a table from a file.
file(path, format, structure)
Input parameters
path
— The relative path to the file from user_files_path.format
— The format of the file.structure
— Structure of the table. Format'colunmn1_name column1_ype, column2_name column2_type, ...'
.
Returned value
A table with the specified structure for reading or writing data in the specified file.
Example
Setting user_files_path
and the contents of the file test.csv
:
$ 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
Table fromtest.csv
and selection of the first two rows from it:
SELECT *
FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32')
LIMIT 2
┌─column1─┬─column2─┬─column3─┐
│ 1 │ 2 │ 3 │
│ 3 │ 2 │ 1 │
└─────────┴─────────┴─────────┘
-- getting the first 10 lines of a table that contains 3 columns of UInt32 type from a CSV file
SELECT * FROM file('test.csv', 'CSV', 'column1 UInt32, column2 UInt32, column3 UInt32') LIMIT 10