postgres export data to csv code example
Example 1: run postgresql dump to csv
\copy (SELECT * FROM persons) to 'C:\tmp\persons_client.csv' with csv
Example 2: postgresql export output table as a csv
COPY table_name TO 'file_name.csv' DELIMITER ',' CSV HEADER;