Save PL/pgSQL output from PostgreSQL to a CSV file

后端 未结 18 2288
名媛妹妹
名媛妹妹 2020-11-22 11:56

What is the easiest way to save PL/pgSQL output from a PostgreSQL database to a CSV file?

I\'m using PostgreSQL 8.4 with pgAdmin III and PSQL plugin where I run que

18条回答
  •  野性不改
    2020-11-22 12:04

    I'm working on AWS Redshift, which does not support the COPY TO feature.

    My BI tool supports tab-delimited CSVs though, so I used the following:

     psql -h dblocation -p port -U user -d dbname -F $'\t' --no-align -c "SELECT * FROM TABLE" > outfile.csv
    

提交回复
热议问题