如何将数据插入到Hive(0.13.1)表中? [英] How to insert data into a Hive(0.13.1) table?
问题描述
我使用Hive版本0.13.1。尝试在现有表中插入数据时出现错误,同时使用以下查询:
pre $ CREATE TABLE table1(order_num int,payment_type varchar(20),category varchar(20));
INSERT INTO TABLE table1 VALUES(151,'cash','lunch');
错误:
ParseException行1:25无法识别'VALUES'附近的输入('select'子句中的'
'151')
搜索时,让每个人都提示上面的查询,但不幸的是它不适用于我。是否由于不同的Hive版本?由于链接这里
需要帮助将数据插入Hive中的现有表。
INSERT INTO TABLE table1 SELECT 151,'cash','lunch';
如果你想插入多个值,那么你可以工会选择
INSERT INTO TABLE table1
SELECT 151,'cash','lunch'
union all
SELECT 152,'money','dinner';
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.
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';
这篇关于如何将数据插入到Hive(0.13.1)表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!