zoukankan      html  css  js  c++  java
  • hive 基础知识1

    hadoop hive (重点)day-6

    他是一个储存仓库

    1)hive的元数据(类似与表,列的长度等)存储在mysql上面

    创建/拷贝建立新表格

    1)create table table_name like old_table //只有表格

    2)create table table_name as select * from old_table

    添加数据四种方法:

    1)insert into table_name select '数据' union all 后面跟数据

    2)with t as (select 数据)insert into table_name select * from t;

    3)1)创建表格时添加 :location 'hdfs路径'

    ​ 2)将本地文件上传到hdfs

    ​ 3)数据将会自动导入表格

    4)load data local inpath '路径' into table 表名(如果不加local则可添加hdfs中的数据)

    清空表内数据: truncate table table_name;

    命令

    1)查看表更详细的信息:desc formatted 表名

    2)显示表格:show create 表名

    3)清空表内数据: truncate table table_name;

    注意点

    1)外部表在创建时多加一个 external,其底部添指定地址location 'hdfs的文件地址'

    2)临时表是在创建是多加一个temporary

    实例一:

    //使用数据库
    use mydemo;(默认数据库名:default)
    //新建一个表
    create table userinfos(
    userid int,
    username structfirstname:string,lastname:string,
    password string,
    likes array<string>,
    scores map<string,int>
    )
    row format delimited 
    fields terminated by '|'
    collection items terminated by ','
    map keys terminated by ':'
    stored as textfile;
    
    
    
    
  • 相关阅读:
    暑期实践
    noi前第十九场 题解
    noi前第十八场 题解
    noi前第十七场 题解
    noi前第十六场 题解
    noi前第十五场 题解
    noi前第十四场 题解
    noi前第十三场 题解
    [NOI2017]游戏「2-SAT」
    空间宝石「最短路+线段树」
  • 原文地址:https://www.cnblogs.com/tudousiya/p/11235242.html
Copyright © 2011-2022 走看看