MySQL LOAD DATA LOCAL INFILE错误

时间:2013-05-07 17:35:11

标签: mysql file-upload csv

我正在尝试使用以下内容为下表上传50K +行数据,但是查询正常,0行影响了消息:

CREATE  TABLE IF NOT EXISTS ConsumerAlpha.HS6Data (
  hs6DataID INT NOT NULL AUTO_INCREMENT,
  hs6Category INT NOT NULL,
  countryID INT NOT NULL,
  year INT NOT NULL,
  dataCode VARCHAR(15) NOT NULL,
  hsValue DEC(20,2) NULL,
  hsWeight DEC(20,2) NULL,
  hsQuantity DEC(20,2) NULL,
  hsUnitID INT NOT NULL,
  dateCreated DATE NOT NULL ,
  lastModified DATETIME NULL DEFAULT NULL ,
  dateDeleted DATETIME NULL DEFAULT NULL ,  
  PRIMARY KEY (hs6DataID) ,
  UNIQUE INDEX hs6DataID_UNIQUE (hs6DataID),
  CONSTRAINT hs6DataCategories
    FOREIGN KEY (hs6Category)
    REFERENCES ConsumerAlpha.HS6CategoriesR02 (hs6Category)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT hs6DataUnits
    FOREIGN KEY (hsUnitID)
    REFERENCES ConsumerAlpha.HSUnits (hsUnitID)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT hs6DataCountries
    FOREIGN KEY (countryID)
    REFERENCES ConsumerAlpha.Countries (countryID)
    ON DELETE NO ACTION
    ON UPDATE NO ACTION,
  CONSTRAINT hs6DataCode
    FOREIGN KEY (dataCode)
    REFERENCES ConsumerAlpha.DataSources (dataCode )
    ON DELETE NO ACTION
    ON UPDATE NO ACTION)

这是我的LOAD DATA LOCAL命令:

LOAD DATA LOCAL 
INFILE '/Users/Esperto007/Dropbox/Data/DataBase/Tables/ComTrade/hsImports_1988.csv' 
INTO TABLE ConsumerAlpha.HS6Data
fields terminated by ','
optionally enclosed by '"'
lines terminated by '\r'
IGNORE 1 LINES
(hs6Category, countryID, year, dataCode, hsValue, hsWeight, hsQuantity, hsUnitID, dateCreated)
SET dateCreated = NOW();

.csv数据符合定义中的数据类型,并且没有IGNORE 1 LINES之后所示的确切顺序的索引列。昨天我已经工作了之前我对python脚本进行了一些更改,生成表主要是为了“清理代码”..任何帮助都有所帮助。

0 个答案:

没有答案