Export data from Postgres as CSV

Exporting data from Postgres as a CSV or tab delimited file can be fairly simple using the COPY command. Examples below. Export an entire table as CSV:

Export an entire table as CSV with Header:

Export query as CSV:

Export query as data tab delimited text file:

Export data directly to

read more