PostgreSQL中整数类型的无效输入语法 [英] Invalid input syntax for type integer in postgresql
本文介绍了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.com;40.23849561;-75.10329704;Tamara Tuma;321500
2;Exxon Mobil;www.exxonmobil.com;41.16915630;-73.84937379;Sung Shields;321510
3;Apple;www.apple.com;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中整数类型的无效输入语法的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文