1. 程式人生 > >Hive 的insert into 和 insert overwrite

Hive 的insert into 和 insert overwrite

區分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