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 是执行 ...
随机推荐
- ALGO-12_蓝桥杯_算法训练_幂方分解(递归)
问题描述 任何一个正整数都可以用2的幂次方表示.例如: =++ 同时约定方次用括号来表示,即ab 可表示为a(b). 由此可知,137可表示为: ()+()+() 进一步:= ++ (21用2表示) ...
- 【springBoot】之starter pom
SpringBoot针对不同业务提供了不同的starter pom,根据springboot版本不同可能有差异. spring-boot-starter springboot核心starter ,包括 ...
- Hadoop概念学习系列之关于hadoop-2.2.0和hadoop2.6.0的winutils.exe、hadoop.dll版本混用(易出错)(四十三)
问题详情是 2016-12-10 23:24:13,317 INFO [org.apache.hadoop.metrics.jvm.JvmMetrics] - Initializing JVM Met ...
- .NET数据请求序列化
这是一个.ner框架中经常用到的数据映射类,此类主要承接业务应用做数据的增删查改操作.通过序列化将查询数据映射为需要的类. 由于经常会用到,这里收藏一下. data用作SQL数据库链接操作: Repo ...
- Consul之:key/value存储
key/value作用 动态修改配置文件 支持服务协同 建立leader选举 提供服务发现 集成健康检查 除了提供服务发现和综合健康检查,Consul还提供了一个易于使用的键/值存储.这可以用来保存动 ...
- 安装spy-debugger查看前端日志
有时需要查看前端页面日志,但是前端同学有时忘记开启vConsole.为了调试方便,最好在本地可以查看前端日志,做到一劳永逸. 1.安装node 网上搜教程 2.安装spy-debugger sudo ...
- js读取iframe里的元素
父层 <div id="SubStepNav" class="SubStepNav"> <iframe src="aaa.html& ...
- 淘宝购买的“公网IP盒子”企业版存在很多问题
现在罗列了几点问题希望官方尽快能得到解决 1:不支持PPPoE拨号(必须让路由器先拨号后再用这个设备上网)2:不支持双线双IP接入3:配置界面不能设置密码(知道内网IP就可以进了)4:不能代理独立IP ...
- MySQL binlog 组提交与 XA(两阶段提交)--1
参考了网上几篇比较靠谱的文章 http://www.linuxidc.com/Linux/2015-11/124942.htm http://blog.csdn.net/woqutechteam/ar ...
- google chrome浏览器 程序无法启动并行配置不正确
启动电脑后打开chrome弹出如下信息: 系统:win7 进入chrome的安装路径 C:\Program Files (x86)\Google\Chrome\Application 两个版本文件夹, ...