Javatpoint Logo
Javatpoint Logo

Hive - Load Data

Once the internal table has been created, the next step is to load the data into it. So, in Hive, we can easily load data from any file to the database.

  • Let's load the data of the file into the database by using the following command: -

Hive Load Data

Here, emp_details is the file name that contains the data.

  • Now, we can use the following command to retrieve the data from the database.

Hive Load Data
Hive Load Data
  • If we want to add more data into the current database, execute the same query again by just updating the new file name.

Hive Load Data
  • Let's check the data of an updated table: -
Hive Load Data
  • In Hive, if we try to load unmatched data (i.e., one or more column data doesn't match the data type of specified table columns), it will not throw any exception. However, it stores the Null value at the position of unmatched tuple.
  • Let's add one more file to the current table. This file contains the unmatched data.
Hive Load Data

Here, the third column contains the data of string type, and the table allows the float type data. So, this condition arises in an unmatched data situation.

  • Now, load the data into the table.

Hive Load Data

Here, data loaded successfully.

  • Let's fetch the records of the table.

Hive Load Data

Here, we can see the Null values at the position of unmatched data.

Next TopicHive - Drop Table




Please Share

facebook twitter google plus pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA