博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
hbase 和 hive 关联表
阅读量:4159 次
发布时间:2019-05-26

本文共 1257 字,大约阅读时间需要 4 分钟。

hive 创建 关联hbase表有2种形式:

第一种:

hive> create table hive(id string,name string, age int)
> stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
> with serdeproperties ("hbase.columns.mapping" = ":key,cf:name,cf:age")
> tblproperties ("hbase.table.name" = "hbase");

这种情况是hbase本来没有这张表。hive建表时创建了hbase表.这种情况下,hdfs的hive表目录有hive文件夹,但是里面没有数据(数据时存在hbase里面的)。

hive> insert overwrite table hive

> select * from test;
当hive使用overwrite关键字进行插入数据时。原本数据不会被删除,有同样的行健会被更新覆盖。因为数据是存在hbase中的,遵守hbase插入数据的规则。

当hive删除hive表时,hbase表也会删除。

当先删除hbase的时候,先disabled table,然后drop table
hbase表就被删除了,zookeeper里面也就删除了。
但是hive里面还在,用show tables还能查出来。mysql中TBLS里面还有hive表的信息。但是用select * from hive 查询的时候报错,表不存在(TableNotFoundException)
然后删除hive里面的表的时候会报错TableNotFoundException)。继续show tables时,发现表已经不在了。TBLS里面也没有hive表了。

第二种:external
hive> create external table hive(id string,name string ,ct string)
> stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
> with serdeproperties ("hbase.columns.mapping" = ":key,cf:name,cf:ct")
> tblproperties ("hbase.table.name" = "hbase");

这种情况是hbase里面已经有这张表了,创建一个hive表去管理这hbase表。

hive> insert overwrite table hive

> select * from test;
当hive使用overwrite关键字进行插入数据时。跟第一种情况一样。

删除hive表对hbase没有影响

但是先删除hbase表hive就会报TableNotFoundException
但是删除hive不会报上面这个错。

转载地址:http://arjxi.baihongyu.com/

你可能感兴趣的文章
Docker第八篇-docker-compose教程(介绍,安装,入门示例)
查看>>
Docker第九篇-docker-compose命令和模板文件说明
查看>>
CSDN-markdown编辑器使用
查看>>
携程Apollo分布式配置中心安装使用
查看>>
Lucene搜索引擎-搜索
查看>>
Slor搜索引擎第一篇-初识
查看>>
Solr搜索引擎第二篇-单机安装、基本使用
查看>>
Linux下OpenJDK安装
查看>>
Solr搜索引擎第五篇-Schema模式和FieldType详解
查看>>
Solr搜索引擎第三篇-两种部署模式详解
查看>>
Solr搜索引擎第四篇-常用命令
查看>>
IntelliJ IDEA单独对java类打JAR包
查看>>
Solr搜索引擎第六篇-Solr集成中文分词器IKAnalyzer
查看>>
Solr搜索引擎第七篇-Schema API详解
查看>>
Solr搜索引擎第八篇-索引提交方式
查看>>
Solr搜索引擎第九篇-DataImportHadler导入MySQL数据超详细
查看>>
Cookie顶级域名、二级域名、三级域名共享
查看>>
Elasticsearch搜索引擎第一篇-ES初识
查看>>
Elasticsearch搜索引擎第二篇-ES单机安装、结合Kibana使用
查看>>
Elasticsearch搜索引擎第三篇-ES集成IKAnalyzer中文分词器
查看>>