Reference article:
https://blog.csdn.net/lifei128/article/details/82393539
Hive supports multi-table insertion, you can use multiple insert clauses in the same query, the advantage is that we only need to scan the source table once to generate multiple disjoint output!
example:
from test1
insert overwrite table test2
partition (age)
select name,address,school,age
insert overwrite table test3
select name,address
The key point of multi-table insertion is to place the table statement "from table name" of the query to be executed at the very beginning.
note:
This is an optimization that can reduce table scans, thereby reducing the number of MR STAGEs in the JOB, for optimization purposes.