How to export data from PostgreSQL table to csv file

We can use COPY command to in PostgreSQL to export data from table to csv file.

>COPY "TABLE" TO 'PATH-TO-CSV' DELIMITER ',' CSV HEADER;

Where,

TABLE need to be replaced with the name of the table from which the data to be exported.
PATH-TO-CSV need to be replaced with the full path to the output csv file.

That's all…

Leave a Reply