【问题标题】:Insert NULL into postrgesql timestamp将 NULL 插入 postgresql 时间戳
【发布时间】:2020-02-01 15:23:11
【问题描述】:

我正在尝试将 csv 文件中的值插入到我的 postgresql 数据库中。 这是我的桌子:

CREATE TABLE AllocatedEICDetail (
  Id                                    SERIAL NOT NULL, 
  EntityCreatedAt                       timestamp(34) with time zone NOT NULL, 
  EntityModifiedAt                      timestamp(34) with time zone NOT NULL, 
  MRID                                  varchar(250), 
  DocStatusValue                        varchar(250), 
  AttributeInstanceComponent            varchar(250), 
  LongNames                             varchar(250), 
  DisplayNames                          varchar(250), 
  LastRequestDateAndOrTime              timestamp(7), 
  DeactivateRequestDateAndOrTime        timestamp(7), 
  MarketParticipantStreetAddressCountry varchar(250), 
  MarketParticipantACERCode             varchar(250), 
  MarketParticipantVATcode              varchar(250), 
  Description                           varchar(255), 
  EICParentMarketDocumentMRID           varchar(250), 
  ELCResponsibleMarketParticipantMRID   varchar(250), 
  IsDeleted                             bool NOT NULL, 
  CONSTRAINT PK_AllocatedEICDetail 
    PRIMARY KEY (Id));

以及我要插入的数据:

Id;EntityCreatedAt;EntityModifiedAt;MRID;DocStatusValue;AttributeInstanceComponent;LongNames;DisplayNames;LastRequestDateAndOrTime;DeactivateRequestDateAndOrTime;MarketParticipantStreetAddressCountry;MarketParticipantACERCode;MarketParticipantVATcode;Description;EICParentMarketDocumentMRID;ELCResponsibleMarketParticipantMRID;IsDeleted
47677;2019-04-01 09:26:51.2053104 +00:00;2019-04-01 09:26:51.2053104 +00:00;10T-1001-10010AS;A05;International;Tie Line Koman-KosovoB;L_KOM-KOSB;2018-10-31 00:00:00.0000000;NULL;NULL;;NULL;Tieline;NULL;10XAL-KESH-----J;0
47678;2019-04-01 09:26:51.2053104 +00:00;2019-04-01 09:26:51.2053104 +00:00;24X-LE-TRADING-N;A05;International;LE Trading a.s.;LE-TRADING;2013-12-18 00:00:00.0000000;NULL;SK;;SK2023878747;Trade Responsible Party;NULL;NULL;0

但是当我尝试将 csv 文件插入 pgAdmin 4 时,我得到了这个错误:

错误:类型时间戳的无效输入语法:“NULL” 上下文:复制分配的eicdetail,第2行,列deactivaterequestdateandortime:“NULL”

有什么想法吗?

【问题讨论】:

    标签: database postgresql csv


    【解决方案1】:

    错误消息暗示您的输入数据中有文字“NULL”(字符串)。您可能应该尝试用空值替换它们,如下所示:

    47677;2019-04-01 09:26:51.2053104 +00:00;2019-04-01 09:26:51.2053104 +00:00;10T-1001-10010AS;A05;International;Tie Line Koman-KosovoB;L_KOM-KOSB;2018-10-31 00:00:00.0000000;;;;;Tieline;;10XAL-KESH-----J;0
    

    【讨论】:

      猜你喜欢
      • 2012-09-11
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-05-19
      • 1970-01-01
      • 2013-09-09
      • 2017-03-06
      • 1970-01-01
      相关资源
      最近更新 更多