Output to CSV in postgres with double-quotes

前端 未结 1 2029
情深已故
情深已故 2021-01-01 23:19

Trying to dump the output of a query into a CSV file in an automated job and running into an issue with fields where the column contains my comma delimiter. With the nature

相关标签:
1条回答
  • 2021-01-01 23:41

    Using FORCE_QUOTE

    Here is how to do:

    psql -U user -h server2 database -c "\copy (select ...) to '~/myfile.csv' WITH (FORMAT CSV, HEADER TRUE, FORCE_QUOTE *);"
    

    COPY command documentation

    0 讨论(0)
提交回复
热议问题