how to convert my PostgreSQL database table into CSV? i need to convert my PostgreSQL table into csv, how to do this?
i have visited many sites they suggest the PostgreSQL command to convert the table into CSV but i always get the error message.

the query i tried was :

COPY persons TO 'C:\tmp\persons_db.csv' DELIMITER ',' CSV HEADER;


but PostgreSQL generates the error message as:

ERROR:  could not open file "/tmp/banke.csv" for writing: No such file or directory
********** Error **********

ERROR: could not open file "/tmp/banke.csv" for writing: No such file or directory
SQL state: 58P01


how to do this?
is there any other software or application that can convert the table into csv ?
if so then please suggest.
thank you all..
On Windows, PostgreSQL runs as "Network Service". "Network Service" will need write permissions to c:\tmp if you want it to write there.

Generally I recommend using psql's \copy command instead of copy, as it doesn't need superuser permission in the db, and can write wherever your shell user can write. 

Open up cmd:

&gt; cd c:\tmp
&gt; set PGDATABASE=$nameOfYourDatabase
&gt; set PGUSER=$pgUsername
&gt; set PGPASSWORD=$thePassword
&gt; psql

&gt; \copy persons to 'persons_db.csv' with (format csv, header true);
&gt; \q