How to insert data into a Hive(0.13.1) table?(如何将数据插入到 Hive(0.13.1) 表中?)
问题描述
我使用的是 Hive 版本 0.13.1.尝试将数据插入现有表时,在使用以下查询时出错:
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');
错误:
ParseException line 1:25 无法识别 'VALUES' 附近的输入'('选择子句中的151"
ParseException line 1:25 cannot recognize input near 'VALUES' '(' '151' in select clause
在搜索时,让每个人都建议上述查询,但不幸的是它对我不起作用.是不是因为 Hive 版本不同?
由于链接here
需要帮助将数据插入到 Hive 中的现有表中.
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.
推荐答案
Hive 直到 .14 版本才提供插入值语句,因此您需要更改语法以执行插入选择语句.
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) 表中?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:如何将数据插入到 Hive(0.13.1) 表中?


- 在SQL中,如何为每个组选择前2行 2021-01-01
- 导入具有可变标题的 Excel 文件 2021-01-01
- 如何使用 pip 安装 Python MySQLdb 模块? 2021-01-01
- 更改自动增量起始编号? 2021-01-01
- SQL 临时表问题 2022-01-01
- 如何将 Byte[] 插入 SQL Server VARBINARY 列 2021-01-01
- 远程 mySQL 连接抛出“无法使用旧的不安全身份验证连接到 MySQL 4.1+"来自 XAMPP 的错误 2022-01-01
- 使用 Oracle PL/SQL developer 生成测试数据 2021-01-01
- 如何将 SonarQube 6.7 从 MySQL 迁移到 postgresql 2022-01-01
- 以一个值为轴心,但将一行上的数据按另一行分组? 2022-01-01