Postgres使用Copy命令将表导出成csv文件的遇到Permission Denied等错误
COPY (select id as ID, description as TNAME from my_table order by id) to ‘C:/exp4analyze/MyTable.csv’ with csv header;
ERROR: could not open file “C:/exp4analyze/MyTable.csv” for writing: No such file or directory
原因:目錄不存在
COPY (select id as ID, description as TNAME from my_table order by id) to ‘C:/exp4analyze/MyTable.csv’ with csv header;
ERROR: could not open file “C:/Users/exp4analyze/MyTable.csv” for writing: Permission denied
原因:不能將導出路徑放在系統文件夾下(C盤其他文件夾可以)
COPY (select id as ID, description as TNAME from my_table order by id) to ‘D:/exp4analyze/MyTable.csv’ with csv header;
Query returned successfully: 279 rows affected, 12 msec execution time.
正確結果
PS:如果出現 Invalid Argument 錯誤,考慮是“命令行”窗口或“pgAdmin”工具缺少管理員權限的原因。
總結
以上是生活随笔為你收集整理的Postgres使用Copy命令将表导出成csv文件的遇到Permission Denied等错误的全部內容,希望文章能夠幫你解決所遇到的問題。
- 上一篇: 假设雨点下落时的阻力与雨滴的平方成正比即
- 下一篇: PostgreSQL将表导出为CSV(服