Load and export data
Data exchange has two parts: a format describes the bytes, and a table schema describes their SQL values. Create explicit target columns before importing rows.
Choose a direction
Formats can support input, output or both. Inspect their registered directions before choosing one:
SELECT name, is_input, is_output
FROM system.formats
WHERE name IN ('csv', 'json_each_row', 'parquet', 'yaml')
ORDER BY name
FORMAT csv;"csv",1,1
"json_each_row",1,1
"parquet",1,1
"yaml",1,1Names use snake_case and ignore ASCII case. CamelCase names are not aliases.
Load rows
Native stdin, native FROM INFILE and HTTP attached input send data to INSERT FORMAT. FROM INFILE reads the client's files. file() instead reads confined regular files under the server's user_files_path and can be used in SELECT or INSERT SELECT.
Most file sources require an explicit column/type list. Only form and parquet_metadata can supply their own column metadata.
Export rows
Use SELECT FORMAT to choose a result encoding. Native --query writes exact bytes to stdout, including binary containers. Redirect binary output to a file rather than treating it as a terminal table.
Guides
- CSV and TSV
- JSON
- Binary files
- Arrow and Avro
- Parquet
- SQL row exchange
- Templates and regular expressions
The format reference defines layouts, settings and type mappings.