zoukankan      html  css  js  c++  java
  • Hive常用命令

    1、创建表:

    create table if not exists employee (eid int,name String,salary String,destination String)
    comment 'employee details'
    ROW FORMAT DELIMITED
    FIELDS TERMINATED BY ' '
    LINES TERMINATED BY ' '
    STORED AS TEXTFILE;
    如果增加分区必须在创建表的时候就创建分区,不然就会报错,创建分区的命令>partition by ‘根据哪个字段分区’,

    create table employee (id int, name String, dept String)
    PARTITIONED BY (year int)
    ROW FORMAT delimited
    fields terminated by ' '
    lines terminated by ' '
    stored as textfile;
    stored as textfile文件格式,文件格式在hive中有三种: textfile、Sequencefile(序列化文件,学hadoop的都会知道啦)、Rcfile。

    2、添加数据到表中

    LOAD DATA INPATH '/data/sample.txt' //HDFS路径
    LOAD DATA LOCAL INPATH '/home/chan/sample.txt' //本地路径
    LOAD DATA:加载数据; LOCAL:本地数据 INPATH:文件的地址
    附加:OVERWRITE:覆盖表中的数据 加overwrite是重写表的数据,不加是追加数据
    插入表数据:insert into employee(eid,name) values (1208,'jack');
    Hive只支持插入不支持修改和删除

    3、重命名表名字

    ALTER TABLE employee RENAME TO emp;

  • 相关阅读:
    2017ICPC南宁补题
    H. The Game of Life
    I
    Twice Equation
    (贪心+队列)String
    Marcin and Training Camp
    莫比乌斯函数模版
    HDU-1695 莫比乌斯反演
    Steps to One DP+莫比乌斯反演
    Educational Codeforces Round 62 (Rated for Div. 2)
  • 原文地址:https://www.cnblogs.com/litstar/p/12133455.html
Copyright © 2011-2022 走看看