-- 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;
-- To stdout
COPY (select * from table) TO STDOUT WITH CSV HEADER;
-- To file
COPY (select * from table) TO '/table.csv' WITH CSV HEADER;
COPY table_name FROM 'C:UsersPublicDocumentsert.txt' DELIMITER ',' CSV
-- make sure to put the file in public folder in windows
-- Or temp folder in linux/mac
-- because it might ask for some permissions...
copy table from '/home/usama/Documents/columns_rearrange.csv' csv header ;
COPY mytable FROM '/path/to/csv/file' WITH CSV HEADER; -- must be superuser