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
I tried several things but few of them were able to give me the desired CSV with header details.
Here is what worked for me.
psql -d dbame -U username \ -c "COPY ( SELECT * FROM TABLE ) TO STDOUT WITH CSV HEADER " > \ OUTPUT_CSV_FILE.csv