• 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
    

      

  • 相关阅读:
    How to check a not defined variable in javascript
    How to scroll the window using JQuery $.scrollTo() function
    jQuery图片滑动
    分享一个提供各种尺寸图片的网站
    页面添加 mask 遮罩层
    input, textarea,监听输入事件
    Google jQuery URL
    在页面内, 滑块位置的控制
    jQuery autoResize
    jQuery banner 滑动
  • 原文地址:https://www.cnblogs.com/tesla-turing/p/11509271.html
Copyright © 2020-2023  润新知