Export PostgreSQL table to csv with header for some columns

suggest change
COPY products(is_public, title, discount) TO 'D:\csv_backup\products_db.csv' DELIMITER ',' CSV HEADER;

COPY categories(name) TO 'D:\csv_backup\categories_db.csv' DELIMITER ',' CSV HEADER;

This is server-side COPY. The path is on the database server, and the role needs permission to write server files (a superuser on older versions; pg_write_server_files later). Use \copy in psql to write a file on the client.

Feedback about page:

Feedback:
Optional: your email if you want me to get back to you:



Table Of Contents