The correct COPY command to load postgreSQL data from csv file that has single-quoted data?

老子叫甜甜 提交于 2019-12-03 11:25:47

Double single quotes (if standard_conforming_strings is on, see the docs)

COPY my_table FROM 'c:\downloads\file.csv' DELIMITERS ',' CSV QUOTE '''';

or use the non-standard PostgreSQL-specific escape string:

COPY my_table FROM 'c:\downloads\file.csv' DELIMITERS ',' CSV QUOTE E'\'';
Rupasa Sushma

Some other people who are experiencing this error may want to check the file to see if it contains a header on the first line. While it wasn't the problem in your case, it is worth noting the way to work around it:

COPY my_table FROM 'c:\downloads\file.csv' WITH DELIMITER ',' CSV HEADER;

Never mind, I got the answer:

COPY my_table FROM 'c:\downloads\file.csv' DELIMITERS ',' CSV QUOTE '''';
易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!