1.10-1.11 hive交互式命令讲解

一、hive 交互式命令参数

#帮助
[root@hadoop-senior hive-0.13.1]# bin/hive -h
Missing argument for option: h
usage: hive
 -d,--define <key=value>          Variable subsitution 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
 -h <hostname>                    connecting to Hive Server on remote host
    --hiveconf <property=value>   Use value for given property
    --hivevar <key=value>         Variable subsitution to apply to hive
                                  commands. e.g. --hivevar A=B
 -i <filename>                    Initialization SQL file
 -p <port>                        connecting to Hive Server on port number
 -S,--silent                      Silent mode in interactive shell
 -v,--verbose                     Verbose mode (echo executed SQL to the



#bin/hive -e    #交互式执行查询
使用:
[root@hadoop-senior hive-0.13.1]# bin/hive -e "select * from db_hive.student;"


#bin/hive -f    #SQL from files;sql语句保存在文件中,如xx.sql,使用文件执行SQL
使用l;
bin/hive -f /opt/datas/hivef.sql
 bin/hive -f /opt/datas/hivef.sql > /opt/datas/123.txt    #将结果写入文件中


#bin/hive -i    #后期再讲


二、hive 交互式命令参数

>quit/exit        #退出命令行,

>set key=value    #设置值

>set        

>!+Linux命令    #在hive中执行Linux的命令
hive (default)> !ls /opt/datas;
hivef.sql
student.txt

>dfs        #在hive中操作hdfs的命令

>query string    #其他很多的查询命令,

查看历史命令:

#在系统当前用的家目录下有一个“.hivehistory”的隐藏文件,存放着hive的历史命令
原文地址:https://www.cnblogs.com/weiyiming007/p/10736322.html