Postgres COPY TO NULL整数

编程入门 行业动态 更新时间:2024-10-24 19:20:03
本文介绍了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整数

本文发布于:2023-05-27 09:57:20,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/285767.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:整数   Postgres   COPY   NULL

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!