zoukankan      html  css  js  c++  java
  • 【Hadoop】HIVE 数据表 使用

    3 使用
    3.1 数据导入
    3.1.1 可以使用命令行导入,也可以直接上传到HDFS的特定目录
    3.1.2 格式问题
    3.1.2.1 缺失/不合法字段默认值为NULL
    3.1.2.2 最好数据是格式化的,不要缺失字段
    3.1.3 从HDFS其他目录导入
    3.1.3.1 hadoop fs -put order_ext.txt / load data inpath '/order_ext.txt' into table tbl_order;
    3.1.3.2 自动移动数据到HDFS特定目录
    3.2 数据表类型
    3.2.1 MANAGED
    3.2.1.1 默认TABLE类型
    3.2.1.2 DROP
    3.2.1.2.1 数据删除,整个目录删除
    3.2.2 EXTERNAL
    3.2.2.1 不要求数据放在特定目录,不影响业务系统的持续运行
    3.2.2.2 示例
    3.2.2.2.1 hadoop fs -mkdir -p /hive_ext hadoop fs -put order_ext.txt /hive_ext //////////////////////////////////////////////////////////////////////////////////////////////////////// create external table tbl_order_ext(id int, name string, size string, price double) row format delimited fields terminated by ' ' location '/hive_ext';
    3.2.2.3 EXTERNAL类型TABLE在HDFS上没有新建特定目录,在HIVE的TBLS表中可以查询
    3.2.2.4 DROP
    3.2.2.4.1 只删除逻辑表(元数据),数据不删除,不影响业务数据
    3.2.3 临时表
    3.2.3.1 CREATE AS
    3.2.3.1.1 参考
    3.2.3.1.1.1 http://blog.chinaunix.net/uid-451-id-3125462.html
    3.2.3.1.2 示例
    3.2.3.1.2.1 create table tbl_order_ctas as select id,name,price from tbl_order; //////////////////////////////////////////////////////////////////////////////////////////////////////// select * from tbl_order_ctas;
    3.2.3.2 INSERT INTO/OVERWRITE
    3.2.3.2.1 参考
    3.2.3.2.1.1 http://www.cnblogs.com/RoadGY/archive/2011/07/22/2114088.html
    3.2.3.2.2 示例
    3.2.3.2.2.1 insert into tbl_order_ctas select id,name,price from tbl_order_ext;
    3.2.4 PARTITION
    3.2.4.1 示例
    3.2.4.1.1 create table tbl_order_pt(id int, name string, size string, price double) partitioned by (month string) row format delimited fields terminated by ' '; //////////////////////////////////////////////////////////////////////////////////////////////////////// load data local inpath 'order_new.txt' into table tbl_order_pt partition(month='201601'); load data local inpath 'order_broken.txt' into table tbl_order_pt partition(month='201602'); //////////////////////////////////////////////////////////////////////////////////////////////////////// select * from tbl_order_pt where month='201602';
     
  • 相关阅读:
    redis--pipelining管道
    插入排序
    选择排序
    冒泡排序
    网页表格导入导出Excel
    easyUI的datagrid表格的使用
    软件工程实践总结(个人)
    Beta答辩总结
    Beta冲刺7
    Beta冲刺6
  • 原文地址:https://www.cnblogs.com/junneyang/p/5895941.html
Copyright © 2011-2022 走看看