hive 中insert into和insert overwrite 的区别 举例

hive 中insert into和insert overwrite 的区别 举例

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;

自己在hive中验证成功:然后做如下解释
1.
比如三张表的数据 id int ,name string,age int
原始三张表中都有一条 001 20 zhangsan 数据
insert into 会将account_tmp表中的所有数据都添加到 account表中
也就是说 执行 insert into 后 account 表中 会有俩条 001 20 zhangsan
而执行 insert overwrite 后 account2表中只有一条 001 20 shangsan
2.
还有一点 insert into tablename tablename表要提前创建(否则会报 table not found) 同理 insert overwrite 后面的表也要提前创建
3.
还有一点 比如原始account_tmp表中 开始有俩条 001 20 zhangsan
执行insert overwrite table account2 select *from account_tmp;
account2 中会有俩条 001 20 zhangsan 【overwrite 只会保证自身表 和后面的select 表中的数据不重复 】

ok 解释完毕 学到了的话 记得点个赞支持一下

评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值