zoukankan      html  css  js  c++  java
  • Hive 6、Hive DML(Data Manipulation Language)

    DML主要是对Hive 表中的数据进行操作的(增 删 改),但是由于Hadoop的特性,所以单条的修改、删除,其性能会非常的低所以不支持进行级操作; 

      主要说明一下最常用的批量插入数据较为常用的方法:

    1、从文件中加载数据

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

      例:

    load data local inpath '/opt/data.txt' overwrite into table table1;
    -- 如果文件存放在HDFS中,则不需要写Local 
    
    语法:Standard syntax:
    INSERT OVERWRITE TABLE 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;
     
    Hive extension (multiple inserts):
    FROM from_statement
    INSERT OVERWRITE TABLE tablename1 [PARTITION (partcol1=val1, partcol2=val2 ...) [IF NOT EXISTS]] select_statement1
    [INSERT OVERWRITE TABLE tablename2 [PARTITION ... [IF NOT EXISTS]] select_statement2]
    [INSERT INTO TABLE tablename2 [PARTITION ...] select_statement2] ...;
    FROM from_statement
    INSERT INTO TABLE tablename1 [PARTITION (partcol1=val1, partcol2=val2 ...)] select_statement1
    [INSERT INTO TABLE tablename2 [PARTITION ...] select_statement2]
    [INSERT OVERWRITE TABLE tablename2 [PARTITION ... [IF NOT EXISTS]] select_statement2] ...;
     
    Hive extension (dynamic partition inserts):
    INSERT OVERWRITE TABLE tablename PARTITION (partcol1[=val1], partcol2[=val2] ...) select_statement FROM from_statement;
    INSERT INTO TABLE tablename PARTITION (partcol1[=val1], partcol2[=val2] ...) select_statement FROM from_statement;
    

      

    FROM page_view_stg pvs
    INSERT OVERWRITE TABLE page_view PARTITION(dt='2008-06-08', country)
    SELECT pvs.viewTime, pvs.userid, pvs.page_url, pvs.referrer_url, null, null, pvs.ip, pvs.cnt
    

      

  • 相关阅读:
    Scilab5.5.2 在Centos5.11下binary安装(注:不是源码编译安装)
    《DSP using MATLAB》Problem 9.5
    Java 出现警告 不能读取AppletViewer的属性文件
    《DSP using MATLAB》Problem 9.4
    《DSP using MATLAB》Problem 9.2
    《DSP using MATLAB》Problem 8.46
    《DSP using MATLAB》Problem 8.45
    风力摆?这是不是太简单了点
    树莓派:基于物联网做的指纹打卡器
    Python之面向对象(一)
  • 原文地址:https://www.cnblogs.com/tesla-turing/p/11509271.html
Copyright © 2011-2022 走看看