PostgreSQL: export resulting data from SQL query to Excel/CSV
Example with Unix-style file name: COPY (SELECT * FROM tbl) TO ‘/var/lib/postgres/myfile1.csv’ format csv; Read the manual about COPY (link to version 8.2). You have to use an absolute path for the target file. Be sure to double quote file names with spaces. Example for MS Windows: COPY (SELECT * FROM tbl) TO E'”C:\\Documents and … Read more