Tuesday, October 1, 2013

Permission denied Error, Export CSV file using COPY TO command in PostgreSQL



In PostgreSQL, COPY command used for exporting or importing data in CSV format.

simple COPY commands for  export the Table data in CSV format.

postgres@boss:~$ psql 
postgres=# COPY Table_Name TO '/root/Desktop/table_data_export.csv';

ERROR:  could not open file "/root/Desktop/ table_data_export.csv" for writing: Permission denied


even i've done all the permission  (chmod and changed the owner (chown) to postgres. Then I tried to export the same on location postgres/data, now problem get solved.

postgres=# COPY Table_Name TO '/home/postgres/data/table_data_export.csv';


Post a Comment