postgres output query results to csv file code example
Example 1: run postgresql dump to csv
\copy (SELECT * FROM persons) to 'C:\tmp\persons_client.csv' with csv
Example 2: postgresql import data from csv
copy table from '/home/usama/Documents/columns_rearrange.csv' csv header ;