我正在尝试通过以下命令将 95 GB CSV文件上传到MySQL数据库(MySQL 5.1.36):
CREATE TABLE MOD13Q1 (
rid INT UNSIGNED NOT NULL AUTO_INCREMENT,
gid MEDIUMINT(6) UNSIGNED NOT NULL ,
yr SMALLINT(4) UNSIGNED NOT NULL ,
dyyr SMALLINT(4) UNSIGNED NOT NULL ,
ndvi DECIMAL(7,4) NOT NULL comment 'NA value is 9',
reliability TINYINT(4) NOT NULL comment 'NA value is 9',
ndviquality1 TINYINT(1) NOT NULL ,
ndviquality2 TINYINT(1) NOT NULL ,
primary key (rid),
key(gid)
) ENGINE = MyISAM ;
LOAD DATA INFILE 'datafile.csv' INTO TABLE MOD13Q1 FIELDS TERMINATED by ',' LINES TERMINATED BY '\r\n'
IGNORE 1 LINES
(gid, yr, dyyr, ndvi, reliability,
ndviquality1, ndviquality2
) ;
我目前正在通过 DOS 运行此脚本,但数据库没有响应。它适用于较小的 CSV 文件(1.5 GB)。它适用于这个文件大小吗?
您对如何更有效/更快地做到这一点有什么建议吗?engine = CSV 会是一个替代方案(索引未激活!->所以查询可能运行得非常慢?)。
更新
感谢您的提示,它工作!
mysql> LOAD DATA INFILE 'E:\\AAJan\\data\\data.csv' INTO TABL
E MOD13Q1
-> FIELDS TERMINATED by ','
-> LINES TERMINATED BY '\r\n'
-> IGNORE 1 LINES
-> (gid, yr, dyyr, ndvi, reliability,
-> ndviquality1, ndviquality2
-> ) ;
Query OK, -1923241485 rows affected (18 hours 28 min 51.26 sec)
Records: -1923241485 Deleted: 0 Skipped: 0 Warnings: 0
mysql>
希望这有助于其他人避免将数据分成块。