最新在导入一些历史数据做数据分析时,发现出现int类型出现' '(空字符串)的错误
问了度娘也没结果,到stack overflow 问了下外国朋友成功解决囖,
这样的问题应该很少见,所以我也就不做过多的解释,直接看mysql语句(红色部分已经标出)
#新建表
drop table if exists src_estate_building_info;
create table src_estate_building_info (
`src_id` int not null,
`src_estate_building_id` int default null,
`build_year` char(255),
`src_street_number_id` int not null,
`block_type` char(255),
`incorporated_owners_id` int default null,
key `estate_building` (`src_estate_building_id`), #同一个楼宇可以关联多个街道号,参考十字路口
unique key `estate_building_street_number` (`src_estate_building_id`, `src_street_number_id`)
) default charset utf8;
#利用load命令导入csv文件
load data local infile '/alidata/address/estate_building_info.csv' into table src_estate_building_info
character set utf8
fields terminated by ',' optionally enclosed by '"'
lines terminated by '\r\n'
ignore 1 lines
(src_id, @vsrc_estate_building_id, build_year, src_street_number_id, block_type,@vincorporated_owners_id)
set
src_estate_building_id = nullif(@vsrc_estate_building_id,''),
incorporated_owners_id = nullif(@vincorporated_owners_id,'');
#end