← All notes

COPY in DuckDB reads and writes CSV, Parquet, and JSON files

Answer: COPY reads a file into a table or writes a table to a file. The examples show CSV, Parquet, and JSON.

Reading

Read a CSV file into the lineitem table, using double quotes, or omitting quotes.

Writing

COPY lineitem TO 'lineitem.csv' (FORMAT csv, DELIMITER '|', HEADER) writes a table to a CSV file. Write a table to a CSV file, using double quotes, or omitting quotes.

Operators in the engine

PhysicalCopyDatabase uses a target_database and create_info entries for SCHEMA_ENTRY, VIEW, and TABLE catalog types. PhysicalCopyToFile tracks the directory relative to the COPY target, with "/" separators. The directory is relative to the COPY target, with "/" separators. Use COPY FROM and COPY TO in SQL for file import and export.

See also

Claims

Sources

License: this note is CC BY 4.0 (https://creativecommons.org/licenses/by/4.0/). Summary by iinventedlight (AI-assisted). Sources: DuckDB, COPY Statement; DuckDB, PhysicalCopyDatabase and PhysicalCopyToFile. MIT; MIT. Text was condensed and changed from the originals.

License: CC-BY-4.0 · Summary by iinventedlight (AI-assisted). Sources: DuckDB, COPY Statement; DuckDB, PhysicalCopyDatabase and PhysicalCopyToFile. MIT; MIT.

Cite this

Permanent ID: iil:note:7t21n5nb

iinventedlight. 2026. "COPY in DuckDB reads and writes CSV, Parquet, and JSON files." iinventedlight Library, iil:note:7t21n5nb, version of 2026-11-20. https://iinventedlight.com/library/notes/duckdb-copy/. License: CC-BY-4.0.

@misc{iil_note_7t21n5nb,
  author = {{iinventedlight}},
  title = {{COPY in DuckDB reads and writes CSV, Parquet, and JSON files}},
  howpublished = {iinventedlight Library},
  year = {2026},
  date = {2026-11-20},
  url = {https://iinventedlight.com/library/notes/duckdb-copy/},
  note = {Permanent ID iil:note:7t21n5nb. License: CC-BY-4.0.},
}

Markdown

Spotted a mistake? Use the MCP feedback tool or email hello@iinventedlight.com. Or Report a correction (no account needed).

Extra files beside this note

These files use this note's license, shown below. Paper extras retain their reproduction status; a link is not a reproduction.

All artifact files (JSON index)

For language models and agents: start at /llms.txt | /agents.md | /.well-known/agent-library.json. This page in Markdown: /library/notes/duckdb-copy.md.