本文介绍了Postgres COPY TO NULL整数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我有一个包含各种列的CSV。其中一列包含整数数据。但是,在运行副本时:
I have a CSV that contains various columns. One of the columns contains integer data. However, when running a copy to:
COPY soc FROM '~/soc.asc' WITH DELIMITER '$';我收到以下信息:
ERROR: invalid input syntax for integer: "" CONTEXT: COPY soc, line 1, column soc_code: ""因为看起来Postgres试图在一个整数中插入一个空字符串。我怎样才能解决这个问题?如果可以帮助我,我真的不想捏造我的架构以适应导入。
as it appears that Postgres is trying to stick an empty string in an integer. How can I fix this? I don't really want to fudge my schema to suit the import if it can be helped.
推荐答案你可以告诉postgres将某些值解释为NULL ,例如:
You can tell postgres to interpret some value as NULL, for example:
COPY soc FROM '~/soc.asc' WITH DELIMITER AS '$' NULL AS ''更多推荐
Postgres COPY TO NULL整数
发布评论