HADOOP-HIVE学习笔记(2) CLI
REF:https://edu.hellobi.com/course/93/play/lesson/2032
HIVE CLI
你也可以命令行设置mapred.map.tasks=10, 这样起效优先级> hiveconf > .xml文件.
-e :
[root@bigdata conf]# hive -e "select * from t2 where id>1" --database hello
2
Time taken: 5.922 seconds, Fetched: 1 row(s)
-S (省略不必要的信息)
[root@bigdata conf]# hive -S -e "select count(1) from t2" --database hello
2
如果不加S的结果是什么呢?
Logging initialized using configuration in jar:file:/home/admin/Downloads/apache-hive-2.3.7/lib/hive-common-2.3.7.jar!/hive-log4j2.properties Async: true OK Time taken: 14.445 seconds OK 2 Time taken: 6.046 seconds, Fetched: 1 row(s)
-f: 运行文件file
[root@bigdata conf]# ls
hive-site.xml t2.hql
[root@bigdata conf]# cat t2.hql
use hello;
select * from t2 where id > 1;
[root@bigdata conf]# hive -f t2.hql --database hello
cd ..回到上层目录后,换种方式运行。
[root@bigdata apache-hive-2.3.7]# hive -f conf/t2.hql --database hello
Logging initialized using configuration in jar:file:/home/admin/Downloads/apache-hive-2.3.7/lib/hive-common-2.3.7.jar!/hive-log4j2.properties Async: true
OK
Time taken: 11.419 seconds
OK
Time taken: 0.088 seconds
OK
2
Time taken: 4.364 seconds, Fetched: 1 row(s)
视频中:对应的hql是sum()求和。 [root@bigdata conf]# hive -f hdfs://localhost:9000/user/root/t2.hql
Hive交互式Shell选项:
reset:参数重置成hive-site.xml的配置
add,list,delete是类似的一组。
!<shell command>:
pwd:
hive> !pwd; /home/admin/Downloads/apache-hive-2.3.7/conf
hive> !ls;
hive> dfs -ls /; Found 2 items drwx------ - root staff 0 2020-05-15 22:48 /tmp drwxr-xr-x - root staff 0 2020-05-16 15:23 /user
hive> dfs -ls /user; Found 2 items drwxr-xr-x - root staff 0 2020-05-16 15:23 /user/hive drwxr-xr-x - root staff 0 2020-05-16 17:41 /user/root
add
hive> add FILE t2.hql;
Added resources: [t2.hql]
结果:
hive> LIST FILE; t2.hql hive> delete FILE t2.hql; hive> list FILE; hive>
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 从 HTTP 原因短语缺失研究 HTTP/2 和 HTTP/3 的设计差异
· AI与.NET技术实操系列:向量存储与相似性搜索在 .NET 中的实现
· 基于Microsoft.Extensions.AI核心库实现RAG应用
· Linux系列:如何用heaptrack跟踪.NET程序的非托管内存泄露
· 开发者必知的日志记录最佳实践
· TypeScript + Deepseek 打造卜卦网站:技术与玄学的结合
· Manus的开源复刻OpenManus初探
· AI 智能体引爆开源社区「GitHub 热点速览」
· 从HTTP原因短语缺失研究HTTP/2和HTTP/3的设计差异
· 三行代码完成国际化适配,妙~啊~