Hive

作者: hehehehe | 来源:发表于2021-09-30 10:16 被阅读0次
alter table poi_release.map_poi_hn_click_validity_problem  add partition(dt = '2021-10-01');

select * from poi_release.map_poi_hn_click_validity_problem where dt = '2021-10-01'

hive> load data inpath 'hdfs:///user/hive/warehouse/poi_release.db/map_poi_hn_click_validity_problem/dt=2021-11-12/part-00100-dae5801c-df2d-400f-9eec-bdb4bc5d1bd6-c000' 
overwrite into table poi_release.map_poi_hn_click_validity_problem partition(dt = '2021-10-01');

hdfs dfs -cp /user/hive/warehouse/poi_release.db/map_poi_hn_click_validity_problem/dt=2021-11-12/part-00100-a94b51a4-c7b8-4ffe-9c8e-bcf96d09850c-c000 
/user/hive/warehouse/poi_release.db/map_poi_hn_click_validity_problem/dt=2021-10-01

hdfs dfs -ls /user/hive/warehouse/poi_release.db/map_poi_hn_click_validity_problem/dt=2021-10-01

show partitions poi_release.map_poi_hn_click_validity_problem;
alter table poi_release.map_poi_hn_click_validity_problem drop partition (dt = '2021-10-01');

基于Hadoop开源数据框架工具Hive,本质上是将HDFS上的数据映射成数据库、数据表等元数据,然后再对这些文件进行检索查询。

1、内部表:导入数据时,将数据移动到hive指定的目录文件中,删除表时,数据也会删除;

2、外部表:建表时添加关键字external,并指定位置,删除表时不会删除源数据。

一、数据

1,tom,music-running-code,c++:98.0-java:76.0-php:65.0
2,jerry,music-code,c++:93.0-java:70.0-php:55.0
3,john,code,go:87.0-python:93.0
二、建表语句

CREATE TABLE table1 (
  id int,
  name string,
  interest array<string>,
  score map<string,string>
 )
row format delimited fields terminated by ','  --列分割
collection items terminated by '-'                  --array分割
map keys terminated by ':'                           --map分割
stored AS textfile;                                       --保存
三、导入数据

load data local inpath '/opt/data/test' overwrite into table table1;

外部表


create external table table2(
id int,name string,interest array<string>,
score map<string,string>)
row format delimited fields terminated by ','
collection items terminated by '-'
map keys terminated by ':' location '/testtable';

desc formatted table2;
创建分区表

create external table table2(
id int,name string,interest array<string>,
score map<string,string>)
partitioned by (year int)
row format delimited fields terminated by ','
collection items terminated by '-'
map keys terminated by ':' stored as textfile;

load data local inpath 'root/testdata.txt' into table
table3 partition(year=2018);

show partitions tables;

alter table table3 add partition(year=2019) 
location '/testtable';

show partitions table3;

alter table table3 drop partition(year=2019);

相关文章

  • 数据仓库Hive

    Hive产生背景 Hive概述 HIve体系架构 Hive部署架构 Hive和RDBMS区别 Hive部署以及快速...

  • 数据查询-Hive基础

    outline 什么是Hive 为什么需要Hive Hive的架构 Hive的常用操作 什么是Hive Hive由...

  • 大数据知识 | hive初识

    hive简介 hive架构 hive是什么 官网这样说:https://hive.apache.org/ hive...

  • Hive | Hive 安装详解

    一、Hive 介绍 二、准备工作 三、Hive下载 四、Hive 安装 五、Hive 启动 一、Hive 介绍 H...

  • Hive日常使用

    hive 创建表: hive 执行: =========================hive 调用Python...

  • Hive常用的几种交互操作

    查看hive下的交互命令方式 -help(hive 外) 命令:bin/hive -helpusage: hive...

  • 【Hive】

    Hive的安装 Hive官网地址 http://hive.apache.org/[http://hive.apac...

  • Hive进阶

    hive配置,命令 hive查询显示列名 hive默认分隔符 \001 hive命令行中查看当前hive环境变量 ...

  • Hive 入门

    Hive官网 Hive概述 Hive 的底层执行引擎有 :MapReduce,Tez,Spark- Hive on...

  • 大数据开发之Hive优化篇2-Hive的explain命令

    备注:Hive 版本 2.1.1 一.Hive explain命令概述 Hive的explain命令用来看Hive...

网友评论

      本文标题:Hive

      本文链接:https://www.haomeiwen.com/subject/qtxunltx.html