PostgreSQL: COPY

https://www.postgresql.org/docs/current/sql-copy.html

COPY your specific query into CSV, text (default), or binary.

It comes with server-side command COPY and client-side command \COPY. Server-side you need superuser priviledge.

\COPY cannot span into multiple lines.

  • Change the delimiter by WITH CSV DELIMITER ','
  • Include SELECT column names by HEADER