zoukankan      html  css  js  c++  java
  • Hive Beeline 官方文档学习

    Beeline 是什么?

    它是一个命令行形式的jdbc客户端。搞Java开发的同学,看到这里就应该知道这货是什么了 ── 它是一个连接数据库的工具。

    只不过Beeline连接的数据库是HiveServer2。

    Beeline 有两种工作模式:内嵌、远程。

    内嵌模式中,会运行一个内嵌的Hive(类似于Hive CLI)。

    远程模式中,通过Thrift协议连接到一个不同的HiveServer2。从Hive 0.14起,Beeline连接HiveServer2 时,还会将HiveServer2 执行查询的日志信息输出到STDERR。

    -- 推荐在生产中使用远程模式,因为更安全,且无需 HDFS/metastore 的访问授权。

    注意,在远程模式下,HiveServer2 只接受有效的Thrift 请求 -- 就算是在HTTP模式中,消息体也需要包含Thrift payload。

    Beeline 的使用示例

    [root@elephant ~]# beeline 
    Beeline version 1.1.0-cdh5.6.0 by Apache Hive
    beeline> help
    !all                Execute the specified SQL against all the current connections
    !autocommit         Set autocommit mode on or off
    !batch              Start or execute a batch of statements
    !brief              Set verbose mode off
    !call               Execute a callable statement
    !close              Close the current connection to the database
    !closeall           Close all current open connections
    !columns            List all the columns for the specified table
    !commit             Commit the current transaction (if autocommit is off)
    !connect            Open a new connection to the database.
    !dbinfo             Give metadata information about the database
    !describe           Describe a table
    !dropall            Drop all tables in the current database
    !exportedkeys       List all the exported keys for the specified table
    !go                 Select the current connection
    !help               Print a summary of command usage
    !history            Display the command history
    !importedkeys       List all the imported keys for the specified table
    !indexes            List all the indexes for the specified table
    !isolation          Set the transaction isolation for this connection
    !list               List the current connections
    !manual             Display the BeeLine manual
    !metadata           Obtain metadata information
    !nativesql          Show the native SQL for the specified statement
    !nullemptystring    Set to true to get historic behavior of printing null as
                        empty string. Default is false.
    !outputformat       Set the output format for displaying results
                        (table,vertical,csv2,dsv,tsv2,xmlattrs,xmlelements, and
                        deprecated formats(csv, tsv))
    !primarykeys        List all the primary keys for the specified table
    !procedures         List all the procedures
    !properties         Connect to the database specified in the properties file(s)
    !quit               Exits the program
    !reconnect          Reconnect to the database
    !record             Record all output to the specified file
    !rehash             Fetch table and column names for command completion
    !rollback           Roll back the current transaction (if autocommit is off)
    !run                Run a script from the specified file
    !save               Save the current variabes and aliases
    !scan               Scan for installed JDBC drivers
    !script             Start saving a script to a file
    !set                Set a beeline variable
    !sh                 Execute a shell command
    !sql                Execute a SQL command
    !tables             List all the tables in the database
    !typeinfo           Display the type map for the current connection
    !verbose            Set verbose mode on
    
    Comments, bug reports, and patches go to ???
    beeline> !connect jdbc:hive2://localhost:10000
    beeline> !tables;
    No current connection
    beeline> !connect jdbc:hive2://elephant:10000
    scan complete in 2ms
    Connecting to jdbc:hive2://elephant:10000
    Enter username for jdbc:hive2://elephant:10000: hive
    Enter password for jdbc:hive2://elephant:10000: **********
    Connected to: Apache Hive (version 1.1.0-cdh5.6.0)
    Driver: Hive JDBC (version 1.1.0-cdh5.6.0)
    Transaction isolation: TRANSACTION_REPEATABLE_READ
    0: jdbc:hive2://elephant:10000>

    上面,通过help查询了Beeline 支持的命令,又通过 !connect jdbc:hive2://elephant:10000 连接到 elephant主机上的HiveServer2。

    下面就来看看还能执行什么操作。

    参考:

    https://cwiki.apache.org//confluence/display/Hive/HiveServer2+Clients

    http://blog.csdn.net/huanggang028/article/details/44591663

  • 相关阅读:
    洛谷 P2888 [USACO07NOV]牛栏Cow Hurdles
    洛谷 P2935 [USACO09JAN]最好的地方Best Spot
    CODEVS 1172 Hankson 的趣味题
    洛谷 P2261 [CQOI2007]余数求和
    洛谷 P1463 [POI2002][HAOI2007]反素数
    洛谷 P3383 【模板】线性筛素数
    1.4.2 solr字段类型--(1.4.2.1)字段类型定义和字段类型属性
    HttpSolrServer-采用静态工厂方法,创建HttpSolrServer单实例
    将字符转换为unicode码
    solrj-WiKi
  • 原文地址:https://www.cnblogs.com/larryzeal/p/6659302.html
Copyright © 2011-2022 走看看