hive cli参数介绍(-e/-f/-S)

HIVE CLI参数介绍:
使用help命令可以查看hive cli参数

-d:指定变量
-e:运行SQL语句
-f:执行sql脚本
-i:初始化sql文件
-S:静默模式,不会打印MapReduce输出信息
-v:打印执行sql

 -d,--define <key=value>          Variable substitution to apply to Hive
                                  commands. e.g. -d A=B or --define A=B
    --database <databasename>     Specify the database to use
 -e <quoted-query-string>         SQL from command line
 -f <filename>                    SQL from files
 -H,--help                        Print help information
    --hiveconf <property=value>   Use value for given property
    --hivevar <key=value>         Variable substitution to apply to Hive
                                  commands. e.g. --hivevar A=B
 -i <filename>                    Initialization SQL file
 -S,--silent                      Silent mode in interactive shell
 -v,--verbose                     Verbose mode (echo executed SQL to the console)

hive -f:

hive -f test.sql

hive -e:

hive -e "select * from test.test8"

hive -S -v -e :
-S:静默模式,不打印MapReduce输出信息
-v:打印执行sql
–hiveconf :设置参数,也可以用来传参
案例:

[hadoop@172 chengpeng]$ hive -v -S --hiveconf hive.cli.print.header=true -e "select user_id,name,address from test.test8 group by user_id,name,address"
SLF4J: Class path contains multiple SLF4J bindings.
SLF4J: Found binding in [jar:file:/usr/local/service/hive/lib/log4j-slf4j-impl-2.6.2.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/service/hive/spark/jars/slf4j-log4j12-1.7.16.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/service/tez/lib/slf4j-log4j12-1.7.10.jar!/org/slf4j/impl/StaticLoggerBinder.class]
SLF4J: Found binding in [jar:file:/usr/local/service/hadoop/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]
select user_id,name,address from test.test8 group by user_id,name,address
user_id		name 	address
1		xiaoming	shanghai
2		xiaolan		beijing

–hiveconf :用来传参
sql脚本:

select * from test.test6 where day='${hiveconf:day}' and requesturl like '%${hiveconf:url}%'  limit 15;
hive -hiveconf day=20151115 -hiveconf url=licaike -f test.sql
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值