-- Client side -This approach does the file handling on the client side
Copy (Select * From foo) To '/tmp/test.csv' With CSV DELIMITER ',' HEADER
-- Server side - This approach runs entirely on the remote server
Copy (Select * From foo) To '/tmp/test.csv' With CSV DELIMITER ',' HEADER;
copy (SELECT * FROM persons) to 'C: mppersons_client.csv' with csv
>psql dbname
psql>f ','
psql>a
psql>o '/tmp/output.csv'
psql>SELECT * from users;
psql>q
----------------------------------
COPY (SELECT * from users) To '/tmp/output.csv' With CSV;
-----------------------------------------
psql -d dbname -t -A -F"," -c "select * from users" > output.csv