带有多个FORCE_QUOTE列的PostgreSQL COPY命令

时间:2015-07-03 10:34:04

标签: postgresql

我正在尝试将表格导出为CSV并强制引用两列。

我尝试过以下命令:

COPY hotel_position_daily TO '/home/ubuntu/export/hotel_position_daily.csv' CSV HEADER FORCE_QUOTE hotelname, city;

导致

ERROR:  syntax error at or near "FORCE_QUOTE"
LINE 1: ...buntu/export/hotel_position_daily.csv' CSV HEADER FORCE_QUOT...

我试过

COPY hotel_position_daily TO '/home/ubuntu/export/hotel_position_daily.csv' WITH (FORMAT CSV, HEADER, FORCE_QUOTE hotelname, city);

导致

ERROR:  argument to option "force_quote" must be a list of column names

我做错了什么?

1 个答案:

答案 0 :(得分:10)

我发现解决方案是

COPY hotel_position_daily TO '/home/ubuntu/export/hotel_position_daily.csv' WITH (FORMAT CSV, HEADER, FORCE_QUOTE(hotelname, city));