为什么无法将.csv复制到pgAdmin 4中的表中?

问题描述 投票:0回答:1

一直试图将我的csv导入pgadmin,但是一直面对这个错误:

ERROR:  invalid input syntax for type timestamp: ""time""  
CONTEXT:  COPY nikon2, line 1, column time: ""time""  
SQL state: 22007

此格式的csv

"time","TOTAL","POSITIVE","NEGATIVE","NEUTRAL"  
"2020-02-17 00:00","4140","457","680","3003"  
"2020-02-18 00:00","3634","255","499","2880"  

并且我已经使用此表创建了一个表

CREATE TABLE file_name (  
time timestamp,  
total integer,  
positive integer,   
negative integer,  
neutral integer);

我每天都使用Excel,但希望将SQL集成到我的工作中。任何关于此的建议以及使用pgadmin的漂亮技巧,将不胜感激,谢谢!

sql postgresql csv pgadmin
1个回答
0
投票

第一行是标题,因此不能导入。

请确保在导入之前指定它:

enter image description here

PS:timeSQL reserved keyword,并且使用其中之一作为列名可能会导致问题

© www.soinside.com 2019 - 2024. All rights reserved.