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.pswp.cn/news/539243.shtml
繁體地址,請注明出處:http://hk.pswp.cn/news/539243.shtml
英文地址,請注明出處:http://en.pswp.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…