数据迁移存储过程(一张表转移到另一张表)
本文档主要是描述怎么在一系列条件下将home_brand_manual_pdf的数据插入到brand_shuomingshu表中
1.首先数据的插入涉及到三张表,分别是home_brand(品牌),home_brand_manual_pdf(品牌pdf手册),brand_shuomingshu(品牌说明书)(此表刚开始没数据,是空表)
2.表结构分别介绍
home_brand( 品牌):
home_brand_manual_pdf (品牌pdf手册):
brand_shuomingshu(品牌说明书)
3.表迁移需要的一系列条件:
home_brand_manual_pdf与brand_shuomingshu表列以及home_brand的关系如下
(1)列对应满足以下关系
home_brand_manual_pdf |
brand_shuomingshu |
home_brand |
id |
pdfId |
|
brandId |
|
id(很重要) |
name |
pdfName |
|
url |
url |
|
downloadUrl |
downloadUrl |
|
site |
site | |
appId |
appId |
|
path |
pdfPath |
|
siteMemo |
memo |
|
size |
pdfSize |
|
error |
pdfError | |
totals |
pdfTotals | |
check |
pdfCheck | |
text |
pdfText | |
status |
pdfStatus | |
createUser |
createUser |
|
createDate |
createDate |
|
updateDate |
updateDate |
|
updateUser |
updateUser |
千万注意:
brandId列的值: 通过brand_shuomingshu.brandName到home_brand表中,根据name查询,得到brand信息,将对应的id,作为home_brand_manual_pdf.brandId
(2)过滤条件brand_shuomingshu表:status > 0 and pdfStatus > 0(即只需要将该条件下的数据迁移到brand_shuomingshu中)
4.通过存储过程迁移数据,通过navicat(mysql可视化根据)建立的存储过程如下(假设存储过程名字为test):
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 |
|
然后执行该存储过程call test即可