Export PostgreSQL table to csv with header for some columns
suggest changeCOPY 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.
Found a mistake? Have a question or improvement idea?
Let me know.
Table Of Contents