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\',\'; 回答1: COPY products_273 TO '/tmp/products_199.csv' WITH (FORMAT CSV, HEADER); as described in the manual. 回答2: From psql command line: \COPY my_table TO 'filename' CSV HEADER no semi-colon at the end. 回答3: instead of just table name, you can also write a