I am wondering how to create or export CSV file from SQL? Is tehre any function for that similar as pgsql2shp????? I would appreciate your ideas, tip or solutions.
+1
A:
You can give this a try. But i believe there may be some syntax changes depending on the version.
COPY (SELECT foo,bar FROM whatever) TO ‘/tmp/dump.csv’ WITH CSV HEADER
gruntled
2010-06-11 13:25:03
I got this message: ERROR: could not open file "/dump.csv" for writing: Permission deniedWhat should i do now?Btw, instead of the query above i wrote:COPY (SELECT * FROM table1) TO '/dump.csv' WITH CSV HEADER because proposed path does not exist.
Z77
2010-06-14 08:17:05
Anyone, please????
Z77
2010-06-14 10:44:46
Ok. I found out that problem was in path. So I changed path to:'C:/Program Files/PostgreSQL/8.4/data/test.csv' and it works now. Obvoiusly some folders has restrictions.
Z77
2010-06-14 11:03:37
A:
If you use pgAdmin, you can export any query you run to a CSV file.
Federico Cristina
2010-06-12 21:28:28