duckdb mydb.duckdb -c "COPY users TO 'users.csv' (HEADER, DELIMITER ',');"

Category: Databases & SQL

duckdb mydb.duckdb -c "COPY users TO 'users.csv' (HEADER, DELIMITER ',');"

Export a table to a CSV file

COPY writes the table to a local file; swap the options for Parquet, JSON, or other formats. The reverse is COPY users FROM 'users.csv'. Related: read_csv_auto.
Looking for more? Search all 7,657 commands — works offline, in English or Spanish, and fixes typos.