Export to CSV and Compress with GZIP in postgres

前端 未结 3 1158
孤街浪徒
孤街浪徒 2021-01-30 13:57

I need to export a big table to csv file and compress it.

I can export it using COPY command from postgres like -

COPY foo_table to \'/tmp/foo_table.csv

3条回答
  •  太阳男子
    2021-01-30 14:36

    You can use directly, as per docs, https://www.postgresql.org/docs/9.4/sql-copy.html

    COPY foo_table to PROGRAM 'gzip > /tmp/foo_table.csv' delimiters',' CSV HEADER;
    

提交回复
热议问题