如果使用Sqoop删除mysql中的数据,并且传递动态日期参数,则使用下方的方法:

创建一个sh文件,内容如下:

#!/bin/sh
 
## 环境变量生效
. /etc/profile
 
#【调度删除导入所在月数据量】
deletym=$(date -d last-day +%Y%m)
 
sqoop eval --connect jdbc:mysql://112.112.10.127:3060/yangyang8848--username root --password yangyang8848--query "delete from yangyang8848 Where ym = '$deletym'"
 
sqoop export --connect "jdbc:mysql://112.112.10.127:3060/yangyang8848?useUnicode=true&characterEncoding=utf-8"  --username root  --password yangyang8848 --table yangyang8848  -hcatalog-database yangyang8848 --hcatalog-table yangyang8848
 

  

posted on 2020-09-18 17:43  大羽治不了水  阅读(467)  评论(0编辑  收藏  举报