mysql 导入脚本6_mysql 导入脚本

[root@master shell]# cat test_sql.sh

#!/bin/bash

Date=`date +"%Y%m%d"`

#log the alter tableAlter_log=/home/shell/a.log#logthe import data

Import_log=/home/shell/output.log#theoption of the alter tableecho $Date>>$Alter_log

SQL="alter tableMI_Medicare_2018_INCR rename MI_Medicare_2018_INCR_${Date}"

Rename=$(mysql -uroot -p123456 CH_MedicareData -s -e "${SQL}")

Tablename=$(mysql -uroot -p123456 CH_MedicareData -s -e "descMI_Medicare_2018_INCR_${Date}")if [! -n "$Tablename"]; thenecho "the MI_Medicare_2018_INCR_${Date}is not existed" >>$Alter_logelseecho "the nameof the MI_Medicare_2018_INCR_${Date} has been changed" >>$Alter_log

fi

#option ofimport dataif [-d "/home/backup/MI_Medicare_2018_INCR_${Date}.sql"]; then

/usr/local/mysql/bin/mysql -uroot -p123456 CH_MedicareData

echo "the followingis the count of source data" >>$Alter_log/usr/local/mysql/bin/mysql -uroot -p123456 CH_MedicareData -e "select Max(Id),CreateDate fromMI_Medicare_2018"elseecho "thefile is not existed" >>$Alter_log

fi

echo "theoption is the FROM MI_Medicare_2018_INCR toMI_Medicare_2018"/usr/local/mysql/bin/mysql -uroot -p123456 <

tee/home/shell/output.logshow databases;useCH_MedicareData;select Max(Id),CreateDate fromMI_Medicare_2018;INSERT INTOMI_Medicare_2018

(INSName, BillNumber, TenBitBillNumber,HospitalCode,TherapyType,MZEnterDate,MZOutDate, MZDays,ZYEnterDate,

ZYOutDate,ZYDays,DiseaseDescription,BillAmount,OwnAmount, SubOwnAmount,PreAmount,ItemA31, ItemA32,

ItemA33,ItemA34,BBD001,BBD002,BBD003,BBD004,BBD005,BBD006,BBD007,BBD008,BBD009,BBD010,IDCardHashCode,CreateDate)SELECTINSName,BillNumber,TenBitBillNumber,HospitalCode,TherapyType, MZEnterDate, MZOutDate,MZDays,ZYEnterDate,

ZYOutDate,ZYDays,DiseaseDescription,BillAmount,OwnAmount,SubOwnAmount,PreAmount,ItemA31,ItemA32,

ItemA33,ItemA34,BBD001,BBD002,BBD003,BBD004,BBD005,BBD006,BBD007,BBD008,BBD009,BBD010,IDCardHashCode,CreateDateFROMMI_Medicare_2018_INCR;select Max(Id),CreateDate from MI_Medicare_2018 a,MI_Medicare_2018_INCR b where a.ID=b.Id and a.CreateDate>b.CreateDate;

notee

EOFexit

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值