O'Reilly logo

Apache Hive Essentials by Dayong Du

Stay ahead with the world's most comprehensive technology and business learning platform.

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, tutorials, and more.

Start Free Trial

No credit card required

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 the SELECT 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| ...

With Safari, you learn the way you learn best. Get unlimited access to videos, live online training, learning paths, books, interactive tutorials, and more.

Start Free Trial

No credit card required