Hive 命令行
hive [-hiveconf x=y]* [<-i filename>]* [<-f filename>|<-e query-string>] [-S]
-i从文件初始化HQL
-e从命令行执行指定的HQL
-f执行HQL脚本
-v输出执行的HQL语句到控制台
-p<port> connect to Hive Server on port number
-hiveconf x=yUse this to set hive/hadoop configuration variables.
Hive 命令行示例
#从命令行执行指定的sql语句
$HIVE_HOME/bin/hive -e 'select a.col from tab1 a'
#以指定的hive环境变量执行指定的sql语句
$HIVE_HOME/bin/hive -e 'select a.col from tab1 a' -hiveconf hive.exec.scratchdir=/home/my/hive_scratch -hiveconf mapred.reduce.tasks=32
#以沉默模式执行指定的sql语句,并将执行结果导出到指定文件
$HIVE_HOME/bin/hive -e 'select a.col from tab1 a' > a.txt
#以非交互式模式执行sql文件
$HIVE_HOME/bin/hive -f /home/my/hive-script.sql
#在进入交互模式之前,执行初始化sql文件
$HIVE_HOME/bin/hive -i /home/my/hive-init.sql
Hive 交互式Shell命令
当命令$HIVE_HOME/bin/hive以不带 -e/-f 选项的方式运行时, hive将进入到交互模式
以;冒号结束命令行
| Command | Description |
|---|---|
| quit | 退出命令行 |
| set <key>=<value> | 设置参数 |
| set -v | 打印出所有Hive支持的命令 |
| add FILE <value> <value>* | 增加一个文件到资源列表. |
| list FILE | 列出所有已经添加的资源 |
| list FILE <value>* | 根据value来查看添加的资源 |
| ! <cmd> | execute a shell command from hive shell |
| dfs <dfs command> | 执行DFS的命令 |
| <query string> | 执行查询并输出到标准输出 |








网友评论