在linux的終端運行:$HIVE_HOME/bin/hive 會進入交互模式;
$HIVE_HOME/bin/hive ?-e或者-f 是非交互模式
1、非交互模式運行HQL語句
$HIVE_HOME/bin/hive -e 'select * from movie limit 10'會顯示mapreduce的進度,但不會進入hive的交互模式,終于現實查詢結果
2、非交互模式運行HQL語句(-S靜音模式)
$HIVE_HOME/bin/hive -S -e 'select * from movie limit 10'增加-S選項,不會顯示mapreduce進度
[hadoop@gaoyuan hive-0.14]$ bin/hive -S -e 'select * from movie limit 10' SLF4J: Class path contains multiple SLF4J bindings. SLF4J: Found binding in [jar:file:/home/hadoop/hadoop-2.4.0/share/hadoop/common/lib/slf4j-log4j12-1.7.5.jar!/org/slf4j/impl/StaticLoggerBinder.class] SLF4J: Found binding in [jar:file:/home/hadoop/hive-0.14/lib/hive-jdbc-0.14.0-SNAPSHOT-standalone.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.slf4j.impl.Log4jLoggerFactory] Error rolling back: Can't call rollback when autocommit=true 1 1 133 8 2 1 720 6 3 1 971 10 4 1 1095 7 5 1 1616 10 6 1 1978 7 7 1 2145 8 8 1 2211 8 9 1 3751 7 10 1 4062 3
$HIVE_HOME/bin/hive -S -e 'select * from movie limit 10' > /gaoyuan/ouput.txt這個會把hive查詢語句的運行結果導入output.txt文件里
4、不進入hive交互模式,運行hive腳本
$HIVE_HOME/bin/hive -f hiveScript.sql
也能夠把輸出結果存入一個文件里
$HIVE_HOME/bin/hive -f hiveScript.sql ?>> /home/username/output.txt?
?
更多文章、技術交流、商務合作、聯系博主
微信掃碼或搜索:z360901061

微信掃一掃加我為好友
QQ號聯系: 360901061
您的支持是博主寫作最大的動力,如果您喜歡我的文章,感覺我的文章對您有幫助,請用微信掃描下面二維碼支持博主2元、5元、10元、20元等您想捐的金額吧,狠狠點擊下面給點支持吧,站長非常感激您!手機微信長按不能支付解決辦法:請將微信支付二維碼保存到相冊,切換到微信,然后點擊微信右上角掃一掃功能,選擇支付二維碼完成支付。
【本文對您有幫助就好】元
