postgresqlcsvexport-to-csvheadingpostgresql-copy

How to export table as CSV with headings on Postgresql?


I'm trying to export a PostgreSQL table with headings to a CSV file via command line, however I get it to export to CSV file, but without headings.

My code looks as follows:

COPY products_273 to '/tmp/products_199.csv' delimiters',';

Solution

  • COPY products_273 TO '/tmp/products_199.csv' WITH (FORMAT CSV, HEADER);
    

    as described in the manual.