Hive命令行参数

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

语法:

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

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

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

-f  从文件中运行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


你可能感兴趣的:(hive)