今天把从Kaggle上下载下来的csv数据导入mysql,想做个统计分析,怎奈csv文件有些大,所以只能用mysql 命令导入,现mark下,以备以后不时之需:
1. 导入:
基本语法:
load data [low_priority] [local] infile ‘file_name txt’ [replace | ignore]
into table tbl_name
[character set gbk]
[fields
[terminated by’t’]
[OPTIONALLY] enclosed by ”]
[escaped by” ]]
[lines terminated by’n’]
[ignore number lines]
[(col_name, )]
导入命令_example:
load data infile ‘csv文件路径test.csv’
replace into table 表名
fields terminated by ‘,’
optionally enclosed by ‘”‘
lines terminated by ‘n’
ignore 1 lines(Id,@dummy,DayOfWeek,PdDistrict,Address,X,Y);
不要小看这个简单的example,包含了很多东西;
第一行就是导入文件;
第二行参看语法就会发现有两个词