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  |
    +------------+-----------+----------------------+--+
  • 相关阅读:
    2017.7.18 linux下ELK环境搭建
    2017.7.18 linux下用户、组和文件的操作
    action解耦方式
    action 耦合方式
    分页查询
    request,response,session
    Struts2
    hibernate中session,HQL,持久化,一对多,多对一
    hibernate 配置文件
    hibernate
  • 原文地址:https://www.cnblogs.com/yy3b2007com/p/7054128.html
Copyright © 2011-2022 走看看