3. Copy (export)#
3.1. Synopsis#
COPY (
SELECT <column_name> [, ...]
FROM <table_name>
[ IN { RANGE <range_spec> | '[' RANGE <range_spec> [, ...] ']' } ]
)
INTO '<absolute_output_path>'
FORMAT[=]{ CSV | TSV | PARQUET | <custom_format_definition> }
[ OVERWRITE[=true] ];
custom_format_definition ::= [ <format_option> [, ...] ]
format_option ::= delimiter=<character>
| quote=<character>
| escape=<character>
| with_header[={true|false}]
3.2. Description#
Use the COPY statement to export data. Do not use an EXPORT statement.
COPY exports columns from one time series table to a CSV, TSV, or Parquet
file.
COPY is available in QuasarDB 3.14.3 and later.
The client that runs the query writes the output file. Specify a fully
qualified absolute path, including the file name, on the client computer. Do
not specify a path on a QuasarDB server. COPY creates the parent
directories if they do not exist.
COPY writes the columns in the order that you specify in the SELECT
list. Use IN RANGE to export one or more time ranges. The syntax is the
same as the syntax for SELECT.
Use IMPORT to load a CSV, TSV, or Parquet export into a table.
3.3. Parameters#
column_nameThe name of a column to export. Specify each column name. Do not use
*or an expression. You can also specify the reserved columns$timestampand$table.table_nameThe name of the time series table to export. Specify one source table by name.
range_specA time range in the form
(<start>, <end>)or(<start>, <offset>). See the SELECT synopsis for the complete range syntax.absolute_output_pathThe fully qualified absolute path to the output file on the client computer. The path is a string and must be enclosed in single quotation marks (
'). An unquoted path or a path in double quotation marks does not parse. Include the directory path and the file name. For example, use'/data/exports/quotes.csv'on Linux or'C:/data/exports/quotes.csv'on Windows.formatThe output format:
CSVComma-delimited text with a header row.
TSVTab-delimited text with a header row.
PARQUETAn Apache Parquet file. Set Parquet compression on the client. The default codec is Snappy.
custom_format_definitionA delimited text format that uses the CSV defaults. You can specify the options in any order:
delimiterThe one-character field delimiter. Defaults to
,.quoteThe one-character quote marker. Defaults to
".escapeThe one-character escape marker. Defaults to a backslash.
with_headerControls whether
COPYwrites the selected column names in the first row. The default value istrue.with_headerwithout a value has the same effect aswith_header=true.
OVERWRITECOPYoverwrites the destination file by default. You can also specifyOVERWRITEorOVERWRITE=true.COPYdoes not supportOVERWRITE=falseand cannot append data to an existing file.
3.4. Limitations#
COPY exports raw table columns and time ranges. It does not support these
SELECT items:
JOIN,WHERE, orPREWHEREclausesGROUP BYclauses or interpolationPIVOT,HAVING, orORDER BYclausesRESTRICT TOclausesAggregate functions or calculations
Qualified column names
FIND(...)orSELECT *
3.5. Examples#
3.5.1. Export selected columns to CSV#
COPY (
SELECT $timestamp, bid, ask FROM quotes
) INTO '/data/exports/quotes.csv' FORMAT=CSV;
3.5.2. Export a time range to TSV#
COPY (
SELECT $timestamp, temperature
FROM sensors
IN RANGE(2026-08-01, 2026-08-02)
) INTO '/data/exports/sensors.tsv' FORMAT=TSV;
3.5.3. Export to Parquet#
COPY (
SELECT $timestamp, bid, ask FROM quotes
) INTO '/data/exports/quotes.parquet' FORMAT=PARQUET;
3.5.4. Export a custom delimited format without a header#
COPY (
SELECT $timestamp, bid, ask FROM quotes
) INTO '/data/exports/quotes.txt'
FORMAT=[delimiter=';', quote='"', escape='\\', with_header=false];
3.5.5. Configure Parquet compression in qdbsh#
The Parquet codec is a client option. It is not part of the COPY syntax.
In qdbsh, set the codec before you run COPY. You can use snappy,
gzip, brotli, zstd, lz4, or uncompressed.
option_set_parquet_compression zstd
COPY (
SELECT $timestamp, bid, ask FROM quotes
) INTO '/data/exports/quotes.parquet' FORMAT=PARQUET;