Loading Data
Function
This topic describes how to use Hive Query Language (HQL) to load data to the existing employees_info table. You can learn how to load data from a local file system and MRS cluster. LOCAL is used to differentiate between local and non-local data sources.
Example Codes
-- Load the employee_info.txt file from the /opt/hive_examples_data/ directory of the local file system to the employees_info table. ---- Overwrite the original data using the new data LOAD DATA LOCAL INPATH '/opt/hive_examples_data/employee_info.txt' OVERWRITE INTO TABLE employees_info; ---- Retain the original data and add the new data to the table. LOAD DATA LOCAL INPATH '/opt/hive_examples_data/employee_info.txt' INTO TABLE employees_info; -- Load /user/hive_examples_data/employee_info.txt from HDFS to the employees_info table. ---- Overwrite the original data using the new data LOAD DATA INPATH '/user/hive_examples_data/employee_info.txt' OVERWRITE INTO TABLE employees_info; ---- Retain the original data and add the new data to the table. LOAD DATA INPATH '/user/hive_examples_data/employee_info.txt' INTO TABLE employees_info;
Loading data is to copy data to a specified table in the Hadoop distributed file system (HDFS).
Sample Data
Data in employees_info is as follows:
1,Wang,R,8000.01,person&personal^Btype&income^Btax&0.05,Country1:City1,2014 3,Tom,D,12000.02,person&personal^Btype&income^Btax&0.09,Country2:City2,2014 4,Jack,D,24000.03,person&personal^Btype&income^Btax&0.05,Country3:City3,2014 6,Linda,D,36000.04,person&personal^Btype&income^Btax&0.05,Country4:City4,2014 8,Zhang,R,9000.05,person&personal^Btype&income^Btax&0.05,Country5:City5,2014
Data in employees_contact is as follows:
1,135 XXXX XXXX,xxxx@xx.com 3,159 XXXX XXXX,xxxxx@xx.com.cn 4,186 XXXX XXXX,xxxx@xx.org 6,189 XXXX XXXX,xxxx@xxx.cn 8,134 XXXX XXXX,xxxx@xxxx.cn
Data in employees_info_extended is as follows:
1,Wang,135 XXXX XXXX,xxxx@xx.com,R,8000.01,person&personal^Btype&income^Btax&0.05,Country1:City1,2014 3,Tom,159 XXXX XXXX,xxxxx@xx.com.cn,D,12000.02,person&personal^Btype&income^Btax&0.09,Country2:City2,2014 4,Jack,186 XXXX XXXX,xxxx@xx.org,D,24000.03,person&personal^Btype&income^Btax&0.05,Country3:City3,2014 6,Linda,189 XXXX XXXX,xxxx@xxx.cn,D,36000.04,person&personal^Btype&income^Btax&0.05,Country4:City4,2014 8,Zhang,134 XXXX XXXX,xxxx@xxxx.cn,R,9000.05,person&personal^Btype&income^Btax&0.05,Country5:City5,2014
Feedback
Was this page helpful?
Provide feedbackThank you very much for your feedback. We will continue working to improve the documentation.See the reply and handling status in My Cloud VOC.
For any further questions, feel free to contact us through the chatbot.
Chatbot