FORMAT 'cbor.cbor'
COPY β¦ FROM Β· import COPY β¦ TO Β· exportCBOR Row Files (COPY FROM / TO). Load a CBOR row file (CBOR Sequence (RFC 8742)) into the COPY target table
-- Export query results to a CBOR row file, one item per row.
COPY (SELECT 1 AS id, 'alpha' AS name) TO 'events.cbor' (FORMAT 'cbor.cbor')
-- Export positionally (each row an array in column order) for a more compact file.
COPY (SELECT 1 AS id, 'alpha' AS name) TO 'events_array.cbor' (FORMAT 'cbor.cbor', row_format 'array')
Options
Pass these inside the COPY statement's parentheses, after FORMAT. Unknown options are rejected.
- row_formatVARCHAR
- How each row is framed as one item: 'map' (default) keys it by column name; 'array' writes the values positionally in column order.
- ignore_errorsBOOLEAN
- Skip incompatible rows with warnings. On a decode error, discard that file's unreadable remainder and continue with the next source (default false). Source-open failures still fail the COPY.
- canonicalVARCHAR
- Deterministic map-key ordering to apply: 'core' (RFC 8949 Β§4.2.1) or 'ctap2'. Unset keeps ciborium's shortest-form output with keys in column order.
Full reference
Bulk import and export of CBOR row files. The file is a CBOR Sequence (RFC 8742) β one item per row, no container header β so it appends, streams, and round-trips between the two directions. The FORMAT identifier is scoped by the ATTACH alias:
COPY (<query>) TO '<path>' (FORMAT '<alias>.cbor');
COPY <table> FROM '<path>' (FORMAT '<alias>.cbor');
row_format 'map' (the default) keys each row by column name; row_format 'array' is positional. On read, ignore_errors true skips unusable rows with warnings. A decode error discards that file's unreadable remainder and continues with the next source; source-open failures still fail the COPY. Writes preserve source order. On write, canonical 'core' (RFC 8949 Β§4.2.1) or canonical 'ctap2' orders map keys deterministically, so the same rows always produce byte-identical output.
Paths are opened by the worker process, so they resolve against its filesystem and working directory rather than the client's β a containerized or remote worker needs a shared location, and absolute paths.