Data exchange – INSERT
To extract the data from Hive tables/ partitions, we can use the INSERT
keyword. Like RDBMS, Hive supports inserting data by selecting data from other tables. This is a very common way to populate a table from existing data. The basic INSERT
statement has the same syntax as a relational database's INSERT
. However, Hive has improved its INSERT
statement by supporting OVERWRITE
, multiple INSERT
, dynamic partition INSERT
, as well as using INSERT
to files. The following are a few examples:
- The following is a regular
INSERT
from theSELECT
statement:--Check the target table, which is empty. jdbc:hive2://> SELECT name, work_place, sex_age . . . . . . .> FROM employee; +-------------+-------------------+----------------+ |employee.name|employee.work_place|employee.sex_age| +-------------+-------------------+----------------+ +-------------+-------------------+----------------+ No rows selected (0.115 seconds) --Populate data from SELECT jdbc:hive2://>...