开发者社区> fate_xuhaidong> 正文

mysql数据库数据定时封装转储

简介: 1.封装转储存储过程 CREATE  PROCEDURE `add_resident_portrait`() BEGIN       TRUNCATE TABLE resident_portrait;   INSERT...
+关注继续查看

1.封装转储存储过程

CREATE  PROCEDURE `add_resident_portrait`()
BEGIN  
    TRUNCATE TABLE resident_portrait;
  INSERT INTO resident_portrait (
    vehicleNumber,
    parkid,
    vehicleType,
    vehicleBrand,
    vehiclePhoto,
    vehicleColor,
    vehicleResidentFlag,
    estate_address,
    building_code,
    unit_code,
    floor,
    areasize,
    house_number,
    estate_type,
    delivery_time,
    checkin_time,
    rent_flag,
    volResource,
    volIntro,
    checkStatus,
    volunteerType,
    signTime,
    nation,
    marr_status,
    edu_status,
    belief,
    height,
    weight,
    resaddr,
    restype,
    healths,
    volunid,
    mail,
    wechat,
    huimg_url,
    blood,
    resimg_url,
    workplace,
    profession,
    address,
    phone_num,
    mobnum,
    political,
    photo_url,
    street,
    cu,
    area,
    pro,
    build,
    NAME,
    sex,
    birthday,
    idcard,
    fatherid,
    motherid
) SELECT
    #车牌号
    vehicleinfo.vehicleNumber,
    #停车场编号
    vehicleinfo.parkid,
    #车辆类型
    vehicleinfo.vehicleType,
    #车辆品牌
    vehicleinfo.vehicleBrand,
    #车辆照片
    vehicleinfo.vehiclePhoto,
    #车辆颜色
    vehicleinfo.vehicleColor,
    #车辆业主属性
    vehicleinfo.vehicleResidentFlag,
    #房产地址
    pr_estate_info.estate_address,
    #楼号
    pr_estate_info.building_code,
    #单元号
    pr_estate_info.unit_code,
    #楼层
    pr_estate_info.floor,
    #面积
    pr_estate_info.area,
    #门牌号
    pr_estate_info.house_number,
    #房产类型
    pr_estate_info.estate_type,
    #交房时间
    pr_estate_info.delivery_time,
    #入住时间
    pr_estate_info.checkin_time,
    #是否出租
    pr_estate_info.rent_flag,
    #志愿者资质
    volunteerinfo.volResource,
    #志愿者可提供服务简介
    volunteerinfo.volIntro,
    #志愿者审核状态
    volunteerinfo.checkStatus,
    #志愿者类型
    volunteerinfo.volunteerType,
    #志愿者注册时间
    volunteerinfo.signTime,
    #民族
    cu_resinfo.nation,
    #婚姻状态
    cu_resinfo.marr_status,
    #教育情况
    cu_resinfo.edu_status,
    #宗教信仰
    cu_resinfo.belief,
    #身高
    cu_resinfo.height,
    #体重
    cu_resinfo.weight,
    #户籍地址
    cu_resinfo.resaddr,
    #户籍类型
    cu_resinfo.restype,
    #健康情况
    cu_resinfo.healths,
    #志愿者id
    cu_resinfo.volunid,
    #邮箱
    cu_resinfo.mail,
    #微信
    cu_resinfo.wechat,
    #房产证照片地址
    cu_resinfo.huimg_url,
    #血型
    cu_resinfo.blood,
    #户口本照片地址
    cu_resinfo.resimg_url,
    #工作单位
    cu_resinfo.workplace,
    #职业
    cu_resinfo.profession,
    #地址
    cu_resinfo.address,
    #固定电话
    cu_resinfo.phone_num,
    #手机
    cu_resinfo.mobnum,
    #政治面貌
    cu_resinfo.political,
    #照片地址
    cu_resinfo.photo_url,
    #所属街道
    cu_resinfo.street,
    #所属社区
    cu_resinfo.cu,
    #所属小区
    cu_resinfo.area,
    #所属物业
    cu_resinfo.pro,
    #所属楼宇
    cu_resinfo.build,
    #姓名
    cu_resinfo. NAME,
    #性别
    cu_resinfo.sex,
    #生日
    cu_resinfo.birthday,
    #身份证号
    cu_resinfo.idcard,
    #父亲id
    cu_resinfo.fatherid,
    #母亲id
    cu_resinfo.motherid
FROM
    cu_resinfo,
    pr_estate_info,
    vehicleinfo,
    volunteerinfo
WHERE
    cu_resinfo.id = vehicleinfo.staffid
AND cu_resinfo.id = pr_estate_info.staffid
AND cu_resinfo.volunid = volunteerinfo.id;
END

2.定时执行任务

CREATE EVENT
dump_resident_portrait

ON SCHEDULE EVERY 7 DAY

STARTS '2018-09-02 00:00:00' DO
 CALL add_resident_portrait;

版权声明:本文内容由阿里云实名注册用户自发贡献,版权归原作者所有,阿里云开发者社区不拥有其著作权,亦不承担相应法律责任。具体规则请查看《阿里云开发者社区用户服务协议》和《阿里云开发者社区知识产权保护指引》。如果您发现本社区中有涉嫌抄袭的内容,填写侵权投诉表单进行举报,一经查实,本社区将立刻删除涉嫌侵权内容。

相关文章
Mysql数据库基础第四章DDL(数据定义语言):库表的管理、数据类型与约束条件
# 1.DDL语言基本概述 DDL:数据定义语言 主要包括以下几部分内容: - 库的管理 - 表的管理 - 数据类型 - 约束 下面我们先介绍库的管理
62 0
mysql 导出查询结果/导入.sql文件数据/mysqldump导出表or数据
mysql 导出查询结果/导入.sql文件数据/mysqldump导出表or数据
44 0
错误代码:1406列的数据太长-MySQL
错误代码:1406列的数据太长-MySQL
22 0
将mysql数据表数据从一台服务器迁移到另一台服务器
这种问题出现在导入表时,也属于权限问题,看mysql中文手册的一段话: >出于安全原因,当读取位于服务器中的文本文件时, www.2cto.com 文件必须位于数据库目录中,或者是全体可读的。另外,要对服务器文件使用LOAD DATA INFILE,您必须拥有FILE权限。
31 0
MySQL 导出 表结构,执行 .sql 文件导入结构或者数据
MySQL 导出 表结构,执行 .sql 文件导入结构或者数据
51 0
mybatis批量更新数据三种方法效率对比【Mysql】
mybatis批量更新数据三种方法效率对比【Mysql】
66 0
Mysql 查询B表的数据新增到A表 (已测试过)
Mysql 查询B表的数据新增到A表 (已测试过)
13 0
eggjs 里链接 mysql 返回数据有 RowDataPacket 应该怎么处理?
eggjs 里链接 mysql 返回数据有 RowDataPacket 应该怎么处理?
16 0
mysql数据库中对数据的基本操作(二)
mysql数据库中对数据的基本操作(二)
38 0
mysql数据库中对数据的基本操作(一)
mysql数据库中对数据的基本操作
15 0
文章
问答
文章排行榜
最热
最新
相关电子书
更多
让 MySQL 原生分布式触手可及
立即下载
好的 MySQL 兼容可以做到什么程度
立即下载
云数据库RDS MySQL从入门到高阶
立即下载