COMMAND: copy (select * from employee) to 'C:/emp.csv' ERROR: could not open file "C:/emp.csv" for writing: Permission denied ********** Error ********** ERROR: could not open file "C:/emp.csv" for writing: Permission denied SQL state: 42501
COMMAND: \copy (select * from employee) to 'C:/emp.csv' ERROR: syntax error at or near "\" LINE 1: \copy (select * from employee) to 'C:/emp.csv' ^ ********** Error ********** ERROR: syntax error at or near "\" SQL state: 42601
Please correct me where I am going wrong. FYI, I am running under the administrator accounts of both Windows Login and PostgreSQL.
Two things,
1. you need to have a proper permissions where the .csv file creating.
2. In windows you need to use as below
postgres=#\copy (select * from employee) to 'C:\\emp.sql'