方法1
tmp_channel_hive_file="/tmp/tmp_channel_hive_file"
tmp_channel_hive_file_new="/tmp/tmp_channel_hive_file_new"
db="t_merchant_shop_channel_top_daily_new"
hive_db="tmp.tmp_test_table"
mysqlhelper -s dbname -e "select id,shop_id,plat,first_channel,second_channel,pv,uv,gmv,amount,paid_uv,paid_order,dt from $db where dt = '$yesday'" > $tmp_channel_hive_file
#打印列写入文件
awk -F"\t" '{for(i=1;i<NF;i++){printf("%s\t",$i);}printf("%s\n",$NF)}' $tmp_channel_hive_file > $tmp_channel_hive_file_new

本地文件导入
hive -e "load data local inpath '${tmp_channel_hive_file_new}' overwrite into table $hive_db PARTITION (dt='$yesday')"

方法2,可以从hive table 表里直接读取插入
hive -e "insert overwrite table tmp.tmp_test_table PARTITION (dt='$yesday')
select id,shop_id,plat,first_channel,second_channel,pv,uv,gmv,amount,paid_uv,paid_order,dt from hive_table where dt = '$yesday'
"

查看写入是否成功

hadoop fs -ls /user/hive/warehouse/hive_table/dt=2016-01*

或者

show partitions hive_table

写hive db的两种方法的更多相关文章

  1. hive权威安装出现的不解错误!(完美解决)两种方法都可以

    以下两种方法都可以,推荐用方法一! 方法一: 步骤一: yum -y install mysql-server 步骤二:service mysqld start 步骤三:mysql -u root - ...

  2. Hive开发中使用变量的两种方法

    在使用hive开发数据分析代码时,经常会遇到需要改变运行参数的情况,比如select语句中对日期字段值的设定,可能不同时间想要看不同日期的数据,这就需要能动态改变日期的值.如果开发量较大.参数多的话, ...

  3. 用js写出光棒效应的两种方法与jquery的两中方法

    <script src="js/jQuery1.11.1.js" type="text/javascript"></script> &l ...

  4. DataGridView显示数据的两种方法

    1.简介 DataGridView空间是我们经常使用的显示数据的控件,它有极高的可配置性和可扩展性. 2.显示数据 DataGridView显示数据一般我们经常使用的有两种方法,一种是直接设置Data ...

  5. Qt连接数据库的两种方法

    我曾经想过,无论在哪个平台下开发,都不要再接触SQL Server了,但显然不行.我们是来看世界的,不是来改变世界的,想通就好. 前两天,尝试了一下Qt下远程访问数据库.在macOS下,用Qt 5.1 ...

  6. [转载]C#读写txt文件的两种方法介绍

    C#读写txt文件的两种方法介绍 by 大龙哥 1.添加命名空间 System.IO; System.Text; 2.文件的读取 (1).使用FileStream类进行文件的读取,并将它转换成char ...

  7. WPF程序将DLL嵌入到EXE的两种方法

    WPF程序将DLL嵌入到EXE的两种方法 这一篇可以看作是<Visual Studio 版本转换工具WPF版开源了>的续,关于<Visual Studio 版本转换工具WPF版开源了 ...

  8. MongoDB实现分页(两种方法)

    1.插入实验数据 偷懒用下samus,100条. ; i < ; i++) { Document doc = new Document(); doc["ID"] = i; d ...

  9. css:图标与文字对齐的两种方法

    (好久没写博客了,这几个月的积累比较零碎,记在本子上,现在开始整理归类) 在平时写页面的过程中,常遇到要把小图标与文字对齐的情况.比如: 总结了两种方法,代码量都比较少. 第一种 对img设置竖直方向 ...

随机推荐

  1. Boo who

    function boo(bool) { // What is the new fad diet for ghost developers? The Boolean. //return bool; r ...

  2. iOS键盘出现时界面跟着往上推

    [[NSNotificationCenter defaultCenter] addObserver:self selector:@selector(keyBoardWillShow:) name:UI ...

  3. 专题:Channel Bonding/bonding

    EtherChannel最初是由cisco提出,通过聚合多条物理链路为单条逻辑链路,从而实现高可用及提高吞吐量等目的.AgP(Port Aggregation Protocol,Cisco专有协议). ...

  4. [2011山东ACM省赛] Sequence (动态规划)

    Sequence Time Limit: 1000ms   Memory limit: 65536K  有疑问?点这里^_^ 题目描述 Given an integer number sequence ...

  5. java实验五20135104

    课程:Java程序设计                   班级:1351            姓名:刘帅      学号:20135104 成绩:             指导教师:娄嘉鹏     ...

  6. 5.4 String

    JAVA 中为什么String 是immutable的? 1.设计:当创建一个String(String str2 = "abc"), 如果它(原先有一个String str = ...

  7. spring常见异常

    1.ClassNotFoundException: org.springframework.dao.support.DaoSupport(解决:导入spring-tx) 2.NoClassDefFou ...

  8. NX 8.5 License Server Firewall Setting

    Reference: http://eng-tips.com/viewthread.cfm?qid=284511 The FLEXNet Server(lmgrd) listens to 28000 ...

  9. [Phalcon-framework] Phalcon framework - Dependency Injection/Service Location And the MVC architecture note 1

    Registering services in the Container - We can easily replace a component with one created by oursel ...

  10. NoSQL精粹(NoSQL Distilled)——序言

    之前说到博客长草的问题,想了想除了很忙特别忙非常忙各种瞎忙忙你妹啊外,主要还是不知道写什么好--到这家公司的两年中从JS到领域驱动到缓存服务器从前端到后端各种折腾,有些东西虽然有所心得,不过既然前人已 ...