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 解释完毕 学到了的话 记得点个赞支持一下