hive与hbase关联表

关于 hbase 和 hive 关联表 详细介绍:


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不会报上面这个错。

转载于:https://www.cnblogs.com/bujunpeng/p/4788279.html

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值