zoukankan      html  css  js  c++  java
  • Sqoop执行mysql删除语句

    如果使用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 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
    
    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
    

     然后通过命令执行sh文件,可能需要sh文件提权,然后才能执行!

  • 相关阅读:
    SQL SERVER 2005 行转列
    为什么jQuery.get、jQuery.getJSON、jQuery.post无法返回JSON
    Silverlight 布局控件
    python socket connection
    linux下缓存的查看/修改
    openstackflat 网络问题
    Fail to start neutronserver
    copy module
    python ConfigParser
    itertools 介绍
  • 原文地址:https://www.cnblogs.com/yangyang8848/p/7699181.html
Copyright © 2011-2022 走看看