PostgreSQL中整数类型的无效输入语法

编程入门 行业动态 更新时间:2024-10-27 22:33:01
本文介绍了PostgreSQL中整数类型的无效输入语法的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

我正在尝试将.csv文件导入我的Postgresql数据库。 我创建了一个表,如下所示:

I'm trying to import a .csv file to my postgresql DB. I created a table as follows:

CREATE TABLE accounts ( acc_id integer, acc_name text, website text, lat numeric, longe numeric, primary_poc text, sales_rep_id integer )

然后我使用以下命令导入.csv文件

Then I used the following command to import the .csv file

COPY accounts(acc_id,acc_name,website,lat,longe,primary_poc,sales_rep_id) FROM 'D:\accounts.csv' DELIMITER ';' CSV ;

我的.csv文件包含以下内容:

And my .csv file contains the following:

1;Walmart;www.walmart;40.23849561;-75.10329704;Tamara Tuma;321500 2;Exxon Mobil;www.exxonmobil;41.16915630;-73.84937379;Sung Shields;321510 3;Apple;www.apple;42.29049481;-76.08400942;Jodee Lupo;321520

但是,这不起作用,并显示以下消息:

However, this doesn't work and the following message appear:

ERROR: invalid input syntax for type integer: "1" CONTEXT: COPY accounts, line 1, column acc_id: "1" SQL state: 22P02

推荐答案

也许有一个 BOM 是CSV吗?

Maybe there is a BOM in the CSV?

  • 将文件十六进制转储,并检查前三个字符
  • (并)使用编辑器删除BOM表
  • (或)再次导出,但不使用BOM表(即使在Microsoft中,也应打勾) ftware)

更多推荐

PostgreSQL中整数类型的无效输入语法

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

发布评论

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

>www.elefans.com

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