shp导入mysql

1.解压软件

将FWTools2.4.7.rar解压到D:\FWTools2.4.7 (无需安装)

2.将shp导入mysql

a 进入dos界面
b cd D:\FWTools2.4.7\bin
c 执行命令:
ogr2ogr -f MySQL MYSQL:数据库名,host=IP地址,user=用户,password=密码,port=端口 -nln 导入后表名 shp文件地址
示例:
ogr2ogr -f MySQL MYSQL:pms,host=localhost,user=root,password=1,port=3306 -nln beacon E:\点位.shp

3.mysql中执行

a 修改double的小数点位
在这里插入图片描述

b beacon点表

select * from point_info 
-- shp文件导入后的表
select * from beacon
-- 批量替换
delete from point_info where layer_id ='B1'set @r:=(select max(id) from point_info);
insert into point_info (id,name,layer_id,longitude,latitude,beacon_id,mac,location_type,status,error_range)
select @r:=@r+1, concat(major,minor),'B1', x,y,concat(uuid,major,minor),`设备id`,1,0,10
from  beacon
-- 根据唯一id,更新
update  point_info a set longitude=(select x from beacon b where  a.beacon_id=concat(b.uuid,b.major,b.minor) ) where a.layer_id='B1';
update  point_info a set latitude=(select y from beacon b where  a.beacon_id=concat(b.uuid,b.major,b.minor) ) where a.layer_id='B1'
update  point_info a set mac=(select `设备id` from beacon b where  a.beacon_id=concat(b.uuid,b.major,b.minor) ) where a.layer_id='B1'

注意:
报错:
在这里插入图片描述

处理:
在这里插入图片描述
在这里插入图片描述

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值