问题
I am using Hive version 0.13.1. While trying to insert data into an existing table getting an error while using the below query:
CREATE TABLE table1 (order_num int, payment_type varchar(20), category varchar(20));
INSERT INTO TABLE table1 VALUES (151, 'cash', 'lunch');
ERROR :
ParseException line 1:25 cannot recognize input near 'VALUES' '(' '151' in select clause
While searching, got everyone suggesting above query, but unfortunately it's not working for me. Is it due to different Hive version?
I am getting this ambiguity due to link here
Needs help to insert data to an existing table in Hive.
回答1:
An insert values statement isn't available in Hive until version .14, so you will need to change your syntax to do a insert select statement.
INSERT INTO TABLE table1 SELECT 151, 'cash', 'lunch';
If you want to insert multiple values then you can union selects
INSERT INTO TABLE table1
SELECT 151, 'cash', 'lunch'
union all
SELECT 152, 'money', 'dinner';
来源:https://stackoverflow.com/questions/43807372/how-to-insert-data-into-a-hive0-13-1-table