hive命令的执行方式
1.通过cli直接执行
2.hive -e "hql"
如:[root@host ~]# hive -e "use gamedw;show tables"
[root@host ~]# hive -e 'use gamedw;show tables'
3.执行文件
[root@host tmpdata]# cat hive.sql
select * from gamedw.v_cust
[root@host ~]# hive -f /root/tmpdata/hive.sql
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/root/hive/apache-hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/spark/spark-2.2.0-bin-hadoop2.7/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/hadoop/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Logging initialized using configuration in file:/root/hive/apache-hive-2.1.1/conf/hive-log4j2.properties Async: true
OK
tianyongtao 1 50 shenzhen
wangwu 1 85 shenzhen
zhangsan 1 20 shenzhen
liuqin 0 56 shenzhen
wangwu 0 47 shenzhen
liuyang 1 32 shenzhen
Time taken: 5.386 seconds, Fetched: 6 row(s)
[root@host ~]# hive -f /root/tmpdata/hive.sql >/root/tmpdata/hivelog.txt //结果保存到本地
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/root/hive/apache-hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/spark/spark-2.2.0-bin-hadoop2.7/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/hadoop/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Logging initialized using configuration in file:/root/hive/apache-hive-2.1.1/conf/hive-log4j2.properties Async: true
OK
Time taken: 4.75 seconds, Fetched: 6 row(s)
[root@host ~]# cat /root/tmpdata/hivelog.txt
tianyongtao 1 50 shenzhen
wangwu 1 85 shenzhen
zhangsan 1 20 shenzhen
liuqin 0 56 shenzhen
wangwu 0 47 shenzhen
liuyang 1 32 shenzhen
同样
hive -i /root/tmpdata/hive.sql 也可以执行hql同时开启cli
hive -hivevar 传递参数
[root@host ~]# cat /root/tmpdata/hivevar.sql
select * from gamedw.v_cust where sex=${varsex} and age>${varage};
[root@host ~]# hive -hivevar varsex=0 -hivevar varage=20 -f /root/tmpdata/hivevar.sql
SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/root/hive/apache-hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/spark/spark-2.2.0-bin-hadoop2.7/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/root/hadoop/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation.
SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Logging initialized using configuration in file:/root/hive/apache-hive-2.1.1/conf/hive-log4j2.properties Async: true
OK
liuqin 0 56 shenzhen
wangwu 0 47 shenzhen
Time taken: 5.839 seconds, Fetched: 2 row(s)
[root@host ~]# hive -e "select * from gamedw.cust">>cust.txt SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/root/hive/apache-hive-2.1.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/spark/spark-2.2.0-bin-hadoop2.7/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/root/hadoop/hadoop-2.7.4/share/hadoop/common/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: See http://www.slf4j.org/codes.html#multiple_bindings for an explanation. SLF4J: Actual binding is of type [org.apache.logging.slf4j.Log4jLoggerFactory]
Logging initialized using configuration in file:/root/hive/apache-hive-2.1.1/conf/hive-log4j2.properties Async: true OK Time taken: 9.204 seconds, Fetched: 19 row(s)
[root@host ~]# cat cust.txt
tianyt_touch100 1 50
wangwu 1 85
zhangsan 1 20
liuqin 0 56
wangwu 0 47
liuyang 1 32
hello 0 100
mahuateng 1 1001
tianyt_touch100 1 50
wangwu 1 85
zhangsan 1 20
liuqin 0 56
wangwu 0 47
xiaomage NULL 51
nihao 1 5
liuyang 1 32
hello 0 100
mahuateng 1 1001
nihao 1 5
hive命令的执行方式的更多相关文章
- hive -help hive命令行执行sql参数
在shell命令行执行 hive -help 结果如下: -d,--define <key=value> Variable substitution to apply to Hive co ...
- hive命令的三种执行方式
hive命令的3种调用方式 方式1:hive –f /root/shell/hive-script.sql(适合多语句) hive-script.sql类似于script一样,直接写查询命令就行 不 ...
- Linux下的Source命令及脚本的执行方式解析
Linux Source命令及脚本的执行方式解析 http://blog.csdn.net/wangyangkobe/article/details/6595143 当我修改了/etc/profile ...
- Source命令及脚本的执行方式
[Source命令及脚本的执行方式] source filename 与 sh filename 及./filename执行脚本的区别在那里呢? 1.当shell脚本具有可执行权限时,用sh file ...
- shell基础概念, if+命令, shell中引用python, shell脚本的几种执行方式
说明: 虚拟机中shell_test目录用来练习shell, 其中有个test.log文件用来存放日志 #!/usr/bin/bash # shell文件开头, 用来指定该文件使用哪个解释器 ...
- ansible的两种命令执行方式 : ad-hoc / playbook以及通过setup模块获取系统参数
一.什么是ad-hoc和playbook ad-hoc : 如果我们敲入一些命令去快速的完成一些操作,而不需要将这些执行过的命令刻意保存下来,这样的命令就叫做as-hoc命令,这里不做过多赘述. p ...
- hive 源码笔记(1):命令行执行的主流程。
1. 'hive'命令是(默认为hive跟目录)./bin下的一个shell脚本,依次加载 ./bin/hive-config.sh, ./conf/hive-env.sh, 设置与hadoop.sp ...
- hadoop笔记之Hive的管理(CLI方式)
Hive的管理(一) Hive的管理(一) Hive的启动方式 CLI(命令行)方式 Web界面方式 远程服务启动方式 CLI方式 1. 进入命令行方式 直接输入<HIVE_HOME>/b ...
- hive 命令行传入参数
azkban实现任务重跑 我们执行sql的方式是将hql文件上传到服务器本地.然后执行shell命令 hive " -f ./test_scheduler.hql 注:hive -e 是执行 ...
随机推荐
- Mysql binlog日志的介绍
mysql的复制功能是 大规模,高性能应用的基础. 分担读负载.水平扩展 是通过二进制日志进行复制,是异步的. 只记录成功执行的修改事件,出现错误的和回滚的是不会纪录的. 日志路径 查看日志 RO ...
- sublime 最近用的有点卡
index_files:false,
- 运营站点-开放robots后,站内google搜索数量第二天10条左右,第5天搜录9920条,可喜可贺
开放robots后,站内google搜索数量第二天10条左右,第5天搜录9920条,可喜可贺 2014年4月29日 16:17:56 到目前为之已搜录14000多条,已有客户在网站注册,加入购物车
- linux下recv 、send阻塞、非阻塞区别和用法
非阻塞IO 和阻塞IO: 在网络编程中对于一个网络句柄会遇到阻塞IO 和非阻塞IO 的概念, 这里对于这两种socket 先做一下说明: 基本概念: 阻塞IO:: socket 的阻塞模式 ...
- NPOI导出Excel2007板
Excel2003有最大行限制相信大家在日常导出时都不会考虑再使用Excel2003,其实NPOI是一个听简单又好用的多里office组件的导出插件. 为了便于以后使用记录一下 第一步下载NPOI插件 ...
- PAT 乙级 1026 程序运行时间(15) C++版
1026. 程序运行时间(15) 时间限制 200 ms 内存限制 65536 kB 代码长度限制 8000 B 判题程序 Standard 作者 CHEN, Yue 要获得一个C语言程序的运行时间, ...
- react中的数据请求
在react中,没有提供专门的请求数据的模块,所以我们可以采用第三方请求数据的模块进行数据请求,常见的有axios和fetch-jsonp,下面来总结这两种方式的用法. axios 查看文档 http ...
- Python 解析XML实例(xml.sax)
已知movies.xml <collection shelf="New Arrivals"> <movie title="Enemy Behind&qu ...
- 在Express中使用Multiparty进行文件上传及POST、GET参数获取
Express 版本:4.14.1 在Express中,文件上传需要用到multiparty中间件,在项目目录中,通过npm install multiparty –save进行安装必要组件. 前端H ...
- [UE4]声音系统概述
一.只能使用wav格式的声音 二.wav声音可以直接播放到打开的UE4编辑器内打开的Content文件夹.也可以直接导入 三.在Content中的文件夹的声音资源可以直接拖放到场景中,会以3D场景声音 ...