多表插入指的是在同一条语句中, 把读取的同一份元数据插入到不同的表中。只需要扫描一遍元数据即可完成所有表的插入操作, 效率很高。多表操作示例如下。
hive> create table mutill as select id,name from userinfo; #有数据 hive> create table mutil2 like mutill; #无数据,只有表结构 hive> from userinfo insert overwrite table mutill select id,name insert overwrite table mutil2 select count(distinct id),name group by name;
from (
from a
select *
) b
left outer join (
from c
select *
) d
on ... = ...
insert overwrite table XXX
select ...