mysql从csv文件导入数据时提示int类型出现' '(空字符串)
2016-06-12 00:31
696 查看
最新在导入一些历史数据做数据分析时,发现出现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
问了度娘也没结果,到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
相关文章推荐
- mysql从csv文件导入数据时提示int类型出现' '(空字符串)
- mysql从csv文件导入数据时提示int类型出现' '(空字符串)
- MySQL与NULL值有关的问题
- cmd安装mysql服务
- win2008 R2 WEB环境配置之MYSQL 5.6.22安装版安装配置方法
- MySQL分表自增ID问题的解决方法
- MySQL ERROR 1045 (28000) 错误的解决办法
- 解压版MySQL-5.6.31-winx64 编码配置
- win下安装mysql5.7.12
- show status(查看mysql状态)
- 跟我一起学习MySQL技术内幕(第五版):(第三章学习日记15)
- 外键约束
- mysql5.5 slave复制从指定位置开始
- mysql 自动递增
- mysql分页查询
- MySQL 全文索引(fulltext)
- Mysql Master-slave 主从配置
- mysql5.5配置半同步复制
- mysqldump 关键参数说明
- mysql5.5 主从复制配置过程