zoukankan      html  css  js  c++  java
  • Hive:insert into table 与 insert overwrite table 区别

    创建测试表,来测试看看测试结果:

    create table test(name string,pwd string,createdate string)row format delimited fields terminated by ',';

    第一步:使用insert into 插入数据到表中:

    insert into test(name,pwd,createdate)values('name1','pwd1','2017-06-20 14:14:09');
    insert into test(name,pwd,createdate)values('name1','pwd1','2017-06-20 14:14:09');
    insert into test(name,pwd,createdate)values('name2','pwd2','2017-06-20 14:14:09');
    insert into test(name,pwd,createdate)values('name2','pwd2','2017-06-20 14:14:09');
    0: jdbc:hive2://10.78.152.52:21066/> select * from test;
    +------------+-----------+----------------------+--+
    | test.name  | test.pwd  |   test.createdate    |
    +------------+-----------+----------------------+--+
    | name1      | pwd1      | 2017-06-20 14:14:09  |
    | name1      | pwd1      | 2017-06-20 14:14:09  |
    | name2      | pwd2      | 2017-06-20 14:14:09  |
    | name2      | pwd2      | 2017-06-20 14:14:09  |
    +------------+-----------+----------------------+--+

    第二步:不清理以上插入的记录,直接执行insert overwirte,并查询分析结果:

    insert overwrite table test select 'name1' as name,'pwd1' as pwd,'2017-06-20 14:14:09' as createdate;
    insert overwrite table test select 'name2' as name,'pwd2' as pwd,'2017-06-20 14:14:09' as createdate;
    insert overwrite table test select 'name2' as name,'pwd2' as pwd,'2017-06-20 14:14:09' as createdate;
    insert overwrite table test select 'name3' as name,'pwd3' as pwd,'2017-06-20 14:14:09' as createdate;
    0: jdbc:hive2://10.78.152.62:21066/> select * from test;
    +------------+-----------+----------------------+--+
    | test.name  | test.pwd  |   test.createdate    |
    +------------+-----------+----------------------+--+
    | name3      | pwd3      | 2017-06-20 14:14:09  |
    +------------+-----------+----------------------+--+

    第三步:不清理上边步骤执行后的结果,接着执行以下sql语句,并查询结果:

    insert overwrite table test select 'name2' as name,'pwd2' as pwd,'2017-06-20 14:14:09' as createdate;
    0: jdbc:hive2://10.78.152.62:21066/> select * from test;
    +------------+-----------+----------------------+--+
    | test.name  | test.pwd  |   test.createdate    |
    +------------+-----------+----------------------+--+
    | name2      | pwd2      | 2017-06-20 14:14:09  |
    +------------+-----------+----------------------+--+
  • 相关阅读:
    HDU 1698 Just a Hook (区间更新+延迟标记)
    HDU 1754 I Hate It 线段树
    HDU 1847 Good Luck in CET-4 Everybody! (sg函数)
    博弈汇总
    Codeforces cf 713A Sonya and Queries
    hihoCoder 1082 : 然而沼跃鱼早就看穿了一切
    hihoCoder 1298 : 数论五·欧拉函数
    hdu 5821 Ball
    hdu 5818 Joint Stacks(栈的模拟)
    hdu 5802 Windows 10
  • 原文地址:https://www.cnblogs.com/yy3b2007com/p/7054128.html
Copyright © 2011-2022 走看看