Exporting CSV from psql.

\f ','
\a
\t
\o some/path.csv

and then run the query. \f sets the field separator, \a sets format to “unaligned”, \t sets “only tuples”. Upon executing the query, the output is written rather than displayed.


  • Postgres 7C1.