Our case is that we need to export part of the data on a large table on the server.


Export data from table with condition to CSV file 

psql -U username -d database -c "COPY (SELECT companies.* FROM companies WHERE companies.country_id = 10) TO stdout WITH DELIMITER ';' CSV" >  country_10_companies.csv


Download CSV data from server local

scp serverip.com:/home/encore/country_10_companies.csv /Users/encore


Import csv data to table

psql -U username -d database -c "COPY companies FROM '/Users/encore/country_10_companies.csv' DELIMITER ';' CSV"