• 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;
    
    
    
    
  • 相关阅读:
    OpenStack--Rabbitmq组件消息队列
    Redis-主从
    haproxy mycat mysql 读写分离MHA高可用
    mysql小白系列_14 线上故障分析与排错
    mysql小白系列_13 Online DDL
    mysql小白系列_12 sysbench
    mysql小白系列_11 MHA补充
    mysql小白系列_11 MHA
    mysql小白系列_10 mysql主从复制原理
    mysql小白系列_09 mysql性能优化关键点
  • 原文地址:https://www.cnblogs.com/tudousiya/p/11235242.html
Copyright © 2020-2023  润新知