插入表格
INSERT INTO 將附加到表或分割槽,保持現有資料不變。
INSERT INTO table yourTargetTable SELECT * FROM yourSourceTable;
如果表被分割槽,那麼我們可以以靜態方式插入到該特定分割槽中,如下所示。
INSERT INTO TABLE yourTargetTable PARTITION (state=CA, city=LIVERMORE)
select * FROM yourSourceTable;
如果表被分割槽,那麼我們可以動態方式插入到該特定分割槽,如下所示。要執行動態分割槽插入,我們必須在下面的屬性下面設定。
Dynamic Partition inserts are disabled by default. These are the relevant configuration properties for dynamic partition inserts:
SET hive.exec.dynamic.partition=true;
SET hive.exec.dynamic.partition.mode=non-strict
INSERT INTO TABLE yourTargetTable PARTITION (state=CA, city=LIVERMORE) (date,time)
select * FROM yourSourceTable;
從表中多次插入。
Hive 擴充套件(多個插入):
FROM table_name
INSERT OVERWRITE TABLE table_one SELECT table_name.column_one,table_name.column_two
INSERT OVERWRITE TABLE table_two SELECT table_name.column_two WHERE table_name.column_one == 'something'