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_name

The name of a column to export. Specify each column name. Do not use * or an expression. You can also specify the reserved columns $timestamp and $table.

table_name

The name of the time series table to export. Specify one source table by name.

range_spec

A time range in the form (<start>, <end>) or (<start>, <offset>). See the SELECT synopsis for the complete range syntax.

absolute_output_path

The 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.

format

The output format:

CSV

Comma-delimited text with a header row.

TSV

Tab-delimited text with a header row.

PARQUET

An Apache Parquet file. Set Parquet compression on the client. The default codec is Snappy.

custom_format_definition

A delimited text format that uses the CSV defaults. You can specify the options in any order:

delimiter

The one-character field delimiter. Defaults to ,.

quote

The one-character quote marker. Defaults to ".

escape

The one-character escape marker. Defaults to a backslash.

with_header

Controls whether COPY writes the selected column names in the first row. The default value is true. with_header without a value has the same effect as with_header=true.

OVERWRITE

COPY overwrites the destination file by default. You can also specify OVERWRITE or OVERWRITE=true. COPY does not support OVERWRITE=false and 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, or PREWHERE clauses

  • GROUP BY clauses or interpolation

  • PIVOT, HAVING, or ORDER BY clauses

  • RESTRICT TO clauses

  • Aggregate functions or calculations

  • Qualified column names

  • FIND(...) or SELECT *

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;