Data Import
Writing to Parquet Files
DuckDB also has support for writing to Parquet files using the `COPY` statement syntax. See the [`COPY` Statement page](#docs:sql:statements:copy) for details, including all possible parameters for the `COPY` statement.  
Write a query to a snappy compressed Parquet file:  
```sql
COPY
(SELECT * FROM tbl)
TO 'result-snappy.parquet'
(FORMAT 'parquet');
```  
Write `tbl` to a zstd-compressed Parquet file:  
```sql
COPY tbl
TO 'result-zstd.parquet'
(FORMAT 'parquet', CODEC 'zstd');
```  
Write `tbl` to a zstd-compressed Parquet file with the lowest compression level yielding the fastest compression:  
```sql
COPY tbl
TO 'result-zstd.parquet'
(FORMAT 'parquet', CODEC 'zstd', COMPRESSION_LEVEL 1);
```  
Write to Parquet file with [key-value metadata](#docs:data:parquet:metadata):  
```sql
COPY (
SELECT
42 AS number,
true AS is_even
) TO 'kv_metadata.parquet' (
FORMAT PARQUET,
KV_METADATA {
number: 'Answer to life, universe, and everything',
is_even: 'not ''odd''' -- single quotes in values must be escaped
}
);
```  
Write a CSV file to an uncompressed Parquet file:  
```sql
COPY
'test.csv'
TO 'result-uncompressed.parquet'
(FORMAT 'parquet', CODEC 'uncompressed');
```  
Write a query to a Parquet file with zstd-compression (same as `CODEC`) and row group size:  
```sql
COPY
(FROM generate_series(100_000))
TO 'row-groups-zstd.parquet'
(FORMAT PARQUET, COMPRESSION ZSTD, ROW_GROUP_SIZE 100_000);
```  
> LZ4 compression is currently only available in the nightly and source builds:  
Write a CSV file to an `LZ4_RAW`-compressed Parquet file:  
```sql
COPY
(FROM generate_series(100_000))
TO 'result-lz4.parquet'
(FORMAT PARQUET, COMPRESSION LZ4);
```  
Or:  
```sql
COPY
(FROM generate_series(100_000))
TO 'result-lz4.parquet'
(FORMAT PARQUET, COMPRESSION LZ4_RAW);
```  
DuckDB's `EXPORT` command can be used to export an entire database to a series of Parquet files. See the [Export statement documentation](#docs:sql:statements:export) for more details:  
Export the table contents of the entire database as Parquet:  
```sql
EXPORT DATABASE 'target_directory' (FORMAT PARQUET);
```