FORMAT 'fixed.fixed'
COPY … FROM · importLoad Fixed-Width File (COPY FROM). Load a fixed-width / flat-file / COBOL-copybook file into the COPY target table
-- Load a file into an existing local table
COPY my_table FROM 'data.fixed' (FORMAT 'fixed.fixed');
Options
Pass these inside the COPY statement's parentheses, after FORMAT. Unknown options are rejected.
- specVARCHAR
- The record layout to decode each row with: a Perl/Python `unpack` template, a JSON field list, or a COBOL copybook. The decoded columns are assigned to the COPY target table's columns by position, so the spec must produce the same number of columns in the same order (each cast to the target column's type).
- formatVARCHAR
- Force how `spec` is interpreted: 'template', 'json', or 'copybook'. Omit to auto-detect.
- encodingVARCHAR
- Byte encoding of the file: 'ascii' (the default) or 'ebcdic' (CP037).
- framingVARCHAR
- How records are delimited: 'newline' (the default), 'fixed', 'rdw', or 'rdw_blocked'.
- record_lengthBIGINT
- The length of each record in BYTES; used only for 'fixed' framing. Defaults to the length implied by the layout `spec`.
- compressionVARCHAR
- Input compression: 'auto' (the default — detect gzip/zstd from the file's magic bytes, else read raw), 'none', 'gzip', or 'zstd'. Applies to local and cloud paths alike; decompression happens before framing/decoding.
- max_decompressed_bytesBIGINT
- Safety cap on total DECOMPRESSED bytes per file (a decompression-bomb backstop; default 16 GiB). Only applies to gzip/zstd input. Raise it to load a legitimately huge compressed file.
- endpointVARCHAR
- Custom S3 endpoint for an `s3://` source (e.g. MinIO/R2 'host:9000'); overrides any endpoint from a CREATE SECRET.
- regionVARCHAR
- AWS region for an `s3://` source. Overrides the region from a CREATE SECRET.
- url_styleVARCHAR
- S3 addressing for an `s3://` source: 'path' (path-style, e.g. MinIO) or 'vhost'.
- use_sslBOOLEAN
- Whether to use TLS for an `s3://` source's custom endpoint (default true).
Full reference
Load a fixed-width file into a table:
COPY <table> FROM '<path>' (FORMAT 'fixed.fixed', spec '<layout>');
Decoded columns map to the target table's columns by position (cast to each type). Named options: spec (required), format, encoding, framing, record_length, and S3 overrides. The COPY-FROM counterpart of read_fixed.