插入表格
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'