zoukankan      html  css  js  c++  java
  • Hive 教程(六)-Hive Cli

    hive 有两种启动方式,一种是 bin/hive,一种是 hiveserver2,

    bin/hive 是 hive 的 shell 模式,所有任务在 shell 中完成,shell 就相当于 hive cli

    hive 命令行参数

    [root@hadoop10 hive2.3.6]# hive --heip
     -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 Batch Mode Commands

    -e:不进入 shell,在 linux 命令行执行 sql

    [root@hadoop10 hive2.3.6]# hive -e 'select * from hive1.hive_01 limit 10';

    注意指定 数据库和数据表

    -f:在文件中执行 sql

    把 sql 语句写入文件,随便什么文件格式

    [root@hadoop10 hive2.3.6]# hive -f sql.sh

    Hive Interactive Shell Commands

    交互命令

    Command

    Description

    quit 
    exit

    Use quit or exit to leave the interactive shell.

    reset

    Resets the configuration to the default values (as of Hive 0.10: see HIVE-3202).

    set <key>=<value>

    Sets the value of a particular configuration variable (key). 
    Note: If you misspell the variable name, the CLI will not show an error.

    set

    Prints a list of configuration variables that are overridden by the user or Hive.

    set -v

    Prints all Hadoop and Hive configuration variables.

    add FILE[S] <filepath> <filepath>*
    add JAR[S] <filepath> <filepath>* 
    add ARCHIVE[S] <filepath> <filepath>*

    Adds one or more files, jars, or archives to the list of resources in the distributed cache. See Hive Resources below for more information.

    add FILE[S] <ivyurl> <ivyurl>* 
    add JAR[S] <ivyurl> <ivyurl>* 
    add ARCHIVE[S] <ivyurl> <ivyurl>*
    As of Hive 1.2.0, adds one or more files, jars or archives to the list of resources in the distributed cache using an Ivy URL of the form ivy://group:module:version?query_string. See Hive Resourcesbelow for more information.

    list FILE[S] 
    list JAR[S] 
    list ARCHIVE[S]

    Lists the resources already added to the distributed cache. See Hive Resources below for more information.

    list FILE[S] <filepath>* 
    list JAR[S] <filepath>* 
    list ARCHIVE[S] <filepath>*

    Checks whether the given resources are already added to the distributed cache or not. See Hive Resources below for more information.

    delete FILE[S] <filepath>* 
    delete JAR[S] <filepath>* 
    delete ARCHIVE[S] <filepath>*

    Removes the resource(s) from the distributed cache.

    delete FILE[S] <ivyurl> <ivyurl>* 
    delete JAR[S] <ivyurl> <ivyurl>* 
    delete ARCHIVE[S] <ivyurl> <ivyurl>*

    As of Hive 1.2.0, removes the resource(s) which were added using the <ivyurl> from the distributed cache. See Hive Resources below for more information.

    ! <command>

    Executes a shell command from the Hive shell.

    dfs <dfs command>

    Executes a dfs command from the Hive shell.

    <query string>

    Executes a Hive query and prints results to standard output.

    source <filepath>

    Executes a script file inside the CLI.

    hive cli 操作 hdfs

    hive> dfs - ls /;

    hive cli 操作本地文件

    hive> ! ls /usr/lib/hive2.3.6;
    bin
    binary-package-licenses
    conf
    examples

    Hive Resources

    参考官网

    参考资料:

    https://cwiki.apache.org/confluence/display/Hive/LanguageManual+Cli  官网

  • 相关阅读:
    【CF global1 D / CF1110D】 Jongmah
    【笔记】数论
    【CF EDU59 D】Compression
    【CF EDU59 E】 Vasya and Binary String (DP)
    【cf527 E】Minimal Diameter Forest
    【模板】分治FFT
    【2018沈阳现场赛I】Distance Between Sweethearts
    【2018沈阳现场赛k】Let the Flames Begin
    【笔记】生成函数与大背包问题
    训练实录 <sudo rm -rf />
  • 原文地址:https://www.cnblogs.com/yanshw/p/11780752.html
Copyright © 2011-2022 走看看