会起作用吗?
MySQL导出:
SELECT * INTO OUTFILE 'C:/data.csv'
FIELDS TERMINATED BY '\t' OPTIONALLY ENCLOSED BY '"'
ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM table;
的PostgreSQL:
COPY table FROM 'C:/data.csv' WITH DELIMITER AS '\t' NULL AS '\\N' CSV
出于某种原因缺少列。所以我相信分隔符存在问题。我纠正了,我该怎么办?我可以检查以下原因错误的行。但是我必须找哪些角色?
ERROR: missing data for column "Column21"
CONTEXT: COPY table, line 88219: ...
答案 0 :(得分:13)
完整代码:
mysql 5.5.15:
SELECT *
INTO OUTFILE 'C:/data.csv'
FIELDS TERMINATED BY '\t' ENCLOSED BY '"' ESCAPED BY '\\'
LINES TERMINATED BY '\n'
FROM table;
postgres 9.0.3:
COPY table FROM 'C:/data.csv' WITH DELIMITER AS '\t' NULL AS '\\N' ESCAPE E'\\' CSV
答案 1 :(得分:0)
PostgreSQL中的默认引号字符是双引号,但the documentation表示,您可以使用任何单个单字节字符。尝试添加
ESCAPE '\\'