IT lexicon › Database › COPY (Postgres)

COPY (Postgres)

Database På svenska → Updated: 2026-05-27

PostgreSQL command for bulk import/export. 10-100x faster than individual INSERTs (one transaction, minimal per-row overhead). Format: CSV, TEXT, BINARY. Standard tool for data migrations.

Syntax: COPY users FROM '/path/users.csv' WITH (FORMAT CSV, HEADER) for file-side, or COPY users FROM STDIN via psql/pg_dump for pipe-based. Client-COPY mode: \copy in psql is client-side (server-COPY requires server-filesystem access). Parallel COPY since PG 14 for large tables. Competitor for bulk load: pg_bulkload (extension, even faster for really large datasets). Modern data pipeline: COPY from CSV in S3 via foreign-data-wrapper (aws_s3).

← Back to the lexicon