Hive的使用之脚本文件


好处

在实际开发中,遇到复杂的hivesql,在文件里先写好再执行,比直接在控制台写更高效,纠错,修改更方便,也易于后期维护。


[hadoop@hello110 ~]$ 模式

在hive没有启动的时候,非hive内,在linux用户输入命令界面。
输入命令后,会启动hive,然后执行。执行完退出hive,每执行一条都要启动,比较耗时。

$>hive -e "sql语句"

[hadoop@hello110 ~]$ hive -e "show tables"
which: no hbase in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hadoop/app/jdk1.8.0_73/bin:/home/hadoop/app/hadoop-2.7.2/bin:/home/hadoop/app/hadoop-2.7.2/sbin:/home/hive2.1/bin:/home/hadoop/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hive2.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/app/hadoop-2.7.2/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:/home/hive2.1/conf/hive-log4j2.properties Async: true
OK
array_test
map_test
student_test
test
test2
test3
Time taken: 3.503 seconds, Fetched: 6 row(s)

-------------------------------------------------------------------------

$>hive -e "sql语句">aaa 

把sql执行结果覆盖到aaa文件里

[hadoop@hello110 ~]$ hive -e "show tables" > aaa
which: no hbase in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hadoop/app/jdk1.8.0_73/bin:/home/hadoop/app/hadoop-2.7.2/bin:/home/hadoop/app/hadoop-2.7.2/sbin:/home/hive2.1/bin:/home/hadoop/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hive2.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/app/hadoop-2.7.2/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:/home/hive2.1/conf/hive-log4j2.properties Async: true
OK
Time taken: 2.508 seconds, Fetched: 6 row(s)

[hadoop@hello110 ~]$ ll
total 384164
-rw-rw-r--. 1 hadoop hadoop        50 Sep  1 18:56 aaa
drwxrwxr-x. 4 hadoop hadoop      4096 Mar 13 04:44 app
-rw-rw-r--. 1 hadoop hadoop       629 Aug 26 05:47 derby.log
-rw-rw-r--. 1 hadoop hadoop 212046774 Mar 12 07:36 hadoop-2.7.2.tar.gz
-rw-rw-r--. 1 hadoop hadoop 181310701 Mar  9 13:31 jdk-8u73-linux-x64.tar.gz
drwxrwxr-x. 5 hadoop hadoop      4096 Aug 26 05:47 metastore_db

[hadoop@hello110 ~]$ more aaa
array_test
map_test
student_test
test
test2
test3

------------------------------------------------------------------------------

$>hive -e "sql语句">>aaa  

把sql执行结果追加到aaa文件里


[hadoop@hello110 ~]$ hive -e "desc map_test" >> aaa             
which: no hbase in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hadoop/app/jdk1.8.0_73/bin:/home/hadoop/app/hadoop-2.7.2/bin:/home/hadoop/app/hadoop-2.7.2/sbin:/home/hive2.1/bin:/home/hadoop/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hive2.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/app/hadoop-2.7.2/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:/home/hive2.1/conf/hive-log4j2.properties Async: true
OK
Time taken: 5.296 seconds, Fetched: 2 row(s)

[hadoop@hello110 ~]$ more aaa
array_test
map_test
student_test
test
test2
test3
id                      string                                      
perf                    map<string,int>            
     
          

----------------------------------------------------------------------------------------------

$>hive -S -e "">aaa  -S

安静地,不打印出内容

-----------------------------------------------------------------------------------------------

$>hive -f file 

在文件里写好sql语句,然后用 hive -f 文件  进行执行。

[hadoop@hello110 ~]$ vi t.sql
show tables;
desc map_test;

[hadoop@hello110 ~]$ hive -f t.sql
which: no hbase in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hadoop/app/jdk1.8.0_73/bin:/home/hadoop/app/hadoop-2.7.2/bin:/home/hadoop/app/hadoop-2.7.2/sbin:/home/hive2.1/bin:/home/hadoop/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hive2.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/app/hadoop-2.7.2/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:/home/hive2.1/conf/hive-log4j2.properties Async: true
OK
array_test
map_test
student_test
test
test2
test3
Time taken: 19.658 seconds, Fetched: 6 row(s)
OK
id                      string                                      
perf                    map<string,int>                             
Time taken: 26.635 seconds, Fetched: 2 row(s)

--------------------------------------------------------------------------------------------------

$>hive -i file

执行完了后,不退出hive,还能操作。


[hadoop@hello110 ~]$ hive -i t.sql
which: no hbase in (/usr/local/bin:/bin:/usr/bin:/usr/local/sbin:/usr/sbin:/sbin:/home/hadoop/app/jdk1.8.0_73/bin:/home/hadoop/app/hadoop-2.7.2/bin:/home/hadoop/app/hadoop-2.7.2/sbin:/home/hive2.1/bin:/home/hadoop/bin)
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/home/hive2.1/lib/log4j-slf4j-impl-2.4.1.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/home/hadoop/app/hadoop-2.7.2/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:/home/hive2.1/conf/hive-log4j2.properties Async: true
array_test
map_test
student_test
test
test2
test3
id                      string                                      
perf                    map<string,int>                             
Hive-on-MR is deprecated in Hive 2 and may not be available in the future versions. Consider using a different execution engine (i.e. spark, tez) or using Hive 1.X releases.
hive> 

---------------


hive> 模式

hive>source file


hive> source t.sql;
OK
array_test
map_test
student_test
test
test2
test3
Time taken: 1.988 seconds, Fetched: 6 row(s)
OK
id                      string                                      
perf                    map<string,int>                             
Time taken: 0.604 seconds, Fetched: 2 row(s)
hive> 





本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.mzph.cn/news/539243.shtml

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈email:809451989@qq.com,一经查实,立即删除!

相关文章

nestjs swagger文档调用需要鉴权的接口

目标 nestjs经常需要设置一些鉴权&#xff08;登录后&#xff09;才能访问的接口&#xff0c;但是生成的swagger文档可以发起接口请求&#xff0c;文档发起的请求默认是不携带登录token的&#xff0c;所以需要移除swagger文档发起请求的守卫拦截。 nestjs守卫拦截设置见另一篇…

ajax预加载html seo,前端性能优化 — JS预加载和懒加载

JS预加载需求&#xff1a;有时我们需要实现例如快速快速切换页面、图片之类的功能时&#xff0c;能尽快的加载出我们所需的图片会极大提升用户体验&#xff0c;这时用预加载将图片先缓存到浏览器&#xff0c;用户使用需显示图片时无疑会顺畅很多。核心&#xff1a;当一个图片在…

面向对象、继承、抽象方法重载知识点整理

面向过程、面向对象 面向过程&#xff1a;从开始到结束自己独立完成 面向对象&#xff1a;将一个事物划分为单体来各自实现区域性的功能&#xff0c;最后通过调用组合完成 类、对象 类&#xff1a;某一些具有共同特征的物体 对象&#xff1a;指某一种具体的物体&#xff0c;属于…

python for循环n次_Python入门10 —— for循环

1.字符串依次取值 students [egon, lxx, alex] i 0 while i < 3: print(students[i]) i 1 2.针对循环取值操作&#xff0c;while循环并不擅长&#xff0c;于是python提供一个专门循环取值操作&#xff1a;for循环 students [egon, lxx, alex] for x in students: # 有几…

hive与依赖环境的交互

与linux交互命令 格式 在linux的命令前加上!&#xff08;英文感叹号&#xff09;&#xff0c;以;&#xff08;英文分号结尾&#xff09; 操作实例 !ls; !pwd; hive> !ls; app derby.log hadoop-2.7.2.tar.gz jdk-8u73-linux-x64.tar.gz metastore_db t.sql hive> !pw…

和平精英显示服务器人数太多,和平精英到底有多差 导致玩家纷纷国际服

原标题&#xff1a;和平精英到底有多差 导致玩家纷纷国际服和平精英上线以来争议不断&#xff0c;百分之九十九是对和平精英的各种不满&#xff0c;还有百分之一是喜欢和平精英&#xff0c;认为刺激战场已经免费给我们玩&#xff0c;让腾讯亏了很多钱&#xff0c;现在和平精英上…

python中的wx_配置 Python的wxWidgets可视开发环境 | 学步园

注&#xff1a;转载请注明出处 一、下载 Python 2.5.1 这一步是必须做的&#xff0c;下载 Python 语言的 SDK 下载地址(直接复制到迅雷)&#xff1a;点击下载 下载完成后安装 Python 2.5.1&#xff0c;注意安装路径中不要有空格&#xff0c;不然会引起一些问题。 二、下载 wxPy…

的write方法有哪些参数_向子进程传递大量数据的方法

如何传递大型数据给子进程昨天的一篇文章中&#xff0c;我们说到如果想向一个子进程传输多于32767个字符的数据&#xff0c;我们需要寻找其他的方法(而不是命令行参数)来实现。我们能想到的第一个方法是&#xff1a;WM_COPYDATA。当子进程创建并进入消息循环后&#xff0c;我们…

厉害了!中关村软件园人工智能军团有料有看点

人工智能已成为当下全球科技界的新热点&#xff0c;中外竞相攀登这座划时代的科技高峰。上月&#xff0c;国务院印发《新一代人工智能发展规划》&#xff0c;明确将人工智能作为未来国家重要的发展战略。《规划》提出前瞻布局新一代人工智能重大科技项目&#xff0c;到2030年中…

Hive的使用之hwi

概述 hwi是hive开发的网页形式查看数据。方便非专业人士使用。 安装步骤 1、下载hive源码包 地址&#xff1a;http://apache.fayea.com/hive/ apache-hive-2.1.0-src.tar.gz 2、打包war 解压apache-hive-2.1.0-src.tar.gz源码包&#xff0c;进入到 C:\Users\zengmg\Deskto…

c 服务器传输大文件,cend.me:不须经过服务器,直接点对点的文件传输免费服务...

要传送文件给远程的手机、平板、电脑等设备&#xff0c;通常的做法就是先将文件上传到服务器存放&#xff0c;然后再从服务器下载&#xff0c;这样的做法看似合理&#xff0c;但如果上传的同时就由远程的设备来接收&#xff0c;不要经过服务器&#xff0c;这样就能更节省上、下…

win10系统迁移后系统重装_win7/win10系统迁移到新SSD硬盘的方法

随着固态硬盘的普及&#xff0c;越来越多的朋友把电脑的硬盘换成了固态&#xff0c;原来的机械硬盘当数据盘使用&#xff0c;关于在固态硬盘中安装系统&#xff0c;那是简单的&#xff0c;和机械硬盘一样&#xff0c;当是对原来的系统比较重要&#xff0c;不能重装的朋友来说&a…

hive参数配置使用

概述 set命令设置hive的参数。 ${} 可以获取配置项的值&#xff0c;作为参数使用。 在启动hive时可以传入配置项启动。 hive参数初始化配置set命令~/.hiverc hive参数介绍 输入set&#xff0c;可以查看所有可设置项和现在设置项的值。 hive> set; 项太多了&#xff…

Thrift源码学习二——Server层

Thrift 提供了如图五种模式&#xff1a;TSimpleServer、TNonblockingServer、THsHaServer、TThreadPoolServer、TThreadSelectorServer ​​ TSimpleServer、TThreadPoolServer 属于阻塞模型 TNonblockingServer、THsHaServer、TThreadedSelectorServer 属于非阻塞模型 TServer…

linux top 命令可视化_25个Linux性能监控工具

一段时间以来&#xff0c;我们在网上向读者介绍了如何为Linux以及类Linux操作系统配置多种不同的性能监控工具。在这篇文章中我们将罗列一系列使用最频繁的性能监控工具&#xff0c;并对介绍到的每一个工具提供了相应的简介链接&#xff0c;大致将其划分为两类&#xff0c;基于…

base64是哪个jar包的_涨知识 | 用maven轻松管理jar包

前言相信只要做过 Java 开发的童鞋们&#xff0c;对 Ant 想必都不陌生&#xff0c;我们往往使用 Ant 来构建项目&#xff0c;尤其是涉及到特别繁杂的工作量&#xff0c;一个 build.xml 能够完成编译、测试、打包、部署等很多任务&#xff0c;这在很大的程度上解放了程序员们的双…

Hive数据类型

概述 Hive的内置数据类型可以分为两大类&#xff1a;(1)、基础数据类型&#xff1b;(2)、复杂数据类型。 基础数据类型 数据类型 所占字节 开始支持版本 TINYINT 1byte&#xff0c;-128 ~ 127 SMALLINT 2byte&#xff0c;-32,768 ~ 32,767 INT 4byte,-2,147,483,648 ~ 2,14…

JMS(Java消息服务)与消息队列ActiveMQ基本使用(一)

最近的项目中用到了mq&#xff0c;之前自己一直在码农一样的照葫芦画瓢。最近几天研究了下&#xff0c;把自己所有看下来的文档和了解总结一下。 一. 认识JMS 1.概述 对于JMS,百度百科&#xff0c;是这样介绍的&#xff1a;JMS即Java消息服务&#xff08;Java Message Service&…

python单词反转_python文本 字符串逐字符反转以及逐单词反转

python文本 字符串逐字符反转以及逐单词反转 场景&#xff1a; 字符串逐字符反转以及逐单词反转 首先来看字符串逐字符反转&#xff0c;由于python提供了非常有用的切片&#xff0c;所以只需要一句就可以搞定了 >>> aabc edf degd >>> a[::-1] dged fde cba …

hive复合数据类型之struct

概述 STRUCT&#xff1a;STRUCT可以包含不同数据类型的元素。这些元素可以通过”点语法”的方式来得到所需要的元素&#xff0c;比如user是一个STRUCT类型&#xff0c;那么可以通过user.address得到这个用户的地址。 操作实例 1、创建表 create table student_test(id int,in…