zoukankan      html  css  js  c++  java
  • [Hive笔记]Hive常用命令整理

    Commonly used Hive Commands

    DDL Commands

    COMMANDOBJECTS
    CREATE Database, Table
    DROP Database, Table
    TRUNCATE Table
    ALTER Database, Table
    SHOW Database, Tables, Table Properties, Partitions, Functions, Index
    DESCRIBE Database, Table, View
    • Create database
    hive> create database if not exist demoDB comment "This is a demo"
    location '/user/hive/warehouse/demodb';
    
    • Drop database
    hive> drop database if not exist demoDB CASCADE;
    
    • Describe database
    hive>describe database extended demoDB;
    
    • Show databases
    hive> show databses;
    
    • Use database
    hive> use demoDB;
    

    DML Commands

    • LOAD

      LOAD DATA [LOCAL] INPATH 'filepath' [OVERWRITE] INTO TABLE [PARTITION (partcol1=val1, partcol2=val2...)]
      

      filepath 可以是:
      *相对路径, 例如 project/data1
      *绝对路径, 例如 /user/hive/project/data1
      *包含schema和authority的完整URL, 例如hdfs://namenode:9000/user/hive/project/data1

      filepath 可以用引用一个文件或者一个目录

      如果指定关键字LOCAL, 那么:

      • load命令将会从本地文件系统中查找文件路径
      • load命令将会拷贝所以文件到目标文件系统

      如果没有指定 LOCAL关键字,那么Hive将使用指定了的完整URL,或者使用以下规则:

      • 如未指定schema或authority, Hive将从记录了namenode URL的配置变量fs.default.name中获取
        *如果路径不是绝对路径,那么Hive将会默认关联/user/
        *Hive会将所有相关文件移动到目前表或分区下
    • INSERT

      Standard Syntax

      INSERT OVERWRITE TBALE tablename1 [PARTITION (partcol1=val1,partcol2=val2) [IF NOT EXISTS]] select_statement1 FROM from_statement;
      INSERT INTO TABLE tablename1 [PARTITION (partcol1=val1,partcol2=val2)] select_statement1 FROM from_statement;
      

      Standard Syntax2

      INSERT INTO TABLE tablename [PARTITION (partcol1=val1, partcol2=val2)] VALUES values_row [, value_row ...];
      
    • UPDATE
      Standard Syntax

       UPDATE tablename SET column = value [, col2 = val2 ] [WHERE expression];
      
    • DELETE
      Standard Syntax

        DELETE FROM tablename [WHERE expression];
      
    • MERGE

    [未完待续]

  • 相关阅读:
    #Laravel 笔记# 多语言化 App::setLocale() 持久化。
    thinkphp 3.2 发送邮件(Phpmailer)
    深度学习的注意力机制
    图像检索引擎vearch安装与测试使用
    word2vector
    GPU环境搭建
    ImportError: libSM.so.6: cannot open shared object file: No such file or dir
    shell中&&和||的用法
    Linux 远程连接sftp与ftp
    mysql-connector-java各版本及与mysql、JDK版本的对应
  • 原文地址:https://www.cnblogs.com/lestatzhang/p/10611338.html
Copyright © 2011-2022 走看看