美文网首页SQL
Hive 的insert into 和 insert overw

Hive 的insert into 和 insert overw

作者: 郝十万 | 来源:发表于2018-08-08 16:35 被阅读558次

区分insert into 和 insert overowrite: 

1、insert into 语句

Hive> insert into table account select id,age,name from account_tmp;

2、insert overwrite语句

hive> insert overwrite table account2 select id,age,name from account_tmp;

插入的数据: 

001 20 zhangsan

两者的区别:

insert overwrite 会覆盖已经存在的数据,假如原始表使用overwrite 上述的数据,先现将原始表的数据remove,再插入新数据。最后表的数据 只有001 20 zhangsan这一条记录。

insert into 只是简单的插入,不考虑原始表的数据,直接追加到表中。最后表的数据是原始数据和新插入的 001 20 zhangsan

相关文章

网友评论

    本文标题:Hive 的insert into 和 insert overw

    本文链接:https://www.haomeiwen.com/subject/pnsxbftx.html