-
Book Overview & Buying
-
Table Of Contents
Getting Started with DuckDB
By :
So far, we have been importing data from a variety of data sources into DuckDB. We also often need to export data from DuckDB into a file, perhaps to transfer to another database system or to share our data with others. Let’s discuss how we can achieve that in the following sections.
We can use the COPY ... TO command to export data from DuckDB to an external CSV, JSON, or Parquet file. This command can be called either with a table name or a query and will export the corresponding data to disk in the desired file format. Let’s try this out by creating a subset of our bike-share dataset and exporting it as a CSV file.
We’ll first create a table called bike_readings_april containing bike rides that occurred in April:
CREATE OR REPLACE TABLE bike_readings_april AS SELECT * FROM bikes WHERE RUNDATE BETWEEN '2017-04-01' AND '2017-04-30';
With the bike_readings_april table created, let...