hive用法-f-e-S-i

$HIVE_HOME/bin/hive是一个shell工具,它可以用来运行于交互或批处理方式配置单元查询。

语法:

Usage: hive [-hiveconf x=y]* [<-i filename>]* [<-f filename>|<-e query-string>] [-S]

-i <filename>: Initialization Sql from file (executed automatically and silently before any other commands)

-e 'quoted query string': 运行引号内sql查询语句 Sql from command line

-f <filename>: 从文件中运行sql语句 Sql from file

-S: Silent mode in interactive shell where only data is emitted

-hiveconf x=y: Use this to set hive/hadoop configuration variables.

-e 与 -f 不能同时使用。In the absence of these options, interactive shell is started. 但是,-i 能够与任意参数同时使用。多个 –i 的实例可以用来执行多个初始化脚本scripts。However, -i can be used with any other options. Multiple instances of -i can be used to execute multiple init scripts.

通过命令:hive –h 可以查看应用的帮助文档.To see this usage help, run hive -h

运行一个查询:

$HIVE_HOME/bin/ hive -e 'select count(*) from c02_clickstat_fatdt1'

Example of setting hive configuration variables

$HIVE_HOME/bin/hive -e 'select a.col from tab1 a' -hiveconfhive.exec.scratchdir=/home/my/hive_scratch -hiveconf mapred.reduce.tasks=32

将查询结果导出到一个文件

HIVE_HOME/bin/hive -S -e ' select count(*) from c02_clickstat_fatdt1' > a.txt

运行一个脚本

HIVE_HOME/bin/hive -f /home/my/hive-script.sql

Example of running an initialization script before entering interactive mode

HIVE_HOME/bin/hive -i /home/my/hive-init.sql

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值