apache hive - HiveQL Loading Data - hive tutorial - hadoop hive - hadoop hive - hiveql
What is Data Loading in HiveQL ?
- Data loading is the process of copying and loading data or data sets from a source file, folder or application to a database or similar application.
- It is usually implemented by copying digital data from a source and pasting or loading the data to a data storage or processing utility.
apache hive - learn hive - hive tutorial - process of hiveql loading data - hive example
apache hive related article tags - hive tutorial - hadoop hive - hadoop hive - hiveql - hive hadoop - learnhive - hive sql
Load Data Statement:
- After creating a table in SQL, we can insert data using the Insert statement.
- But in Hive, we can insert data using the LOAD DATA statement.
- While inserting data into Hive, it is better to use LOAD DATA to store bulk records.
- There are two ways to load data: one is from local file system and second is from Hadoop file system.
Syntax :
The syntax for load data is as follows:
- LOCAL is identifier to specify the local path. It is optional.
- OVERWRITE is optional to overwrite the data in the table.
- PARTITION is optional.
Example:
We will insert the following data into the table. It is a text file named sample.txt in /home/user directory.
1201 | Aarthi | 45000 | Technical manager |
1202 | Boomi | 45000 | Proofreader |
1203 | Dharsanya | 40000 | Technical writer |
1204 | Harikka | 40000 | Hr Admin |
1205 | Mirunalini | 30000 | Op Admin |
The following query loads the given text into the table.
On successful download, you get to see the following response:
JDBC Program:
Given below is the JDBC program to load given data into the table.
Save the program in a file named WikitechyLoadData.java. Use the following commands to compile and execute this program.
Output:
- Load Data into wikitechy_employee successful