hive和hbase的联合表

在hive中创建表: 主键,账户状态,余额,同时定义好其在hbase中的mapping表名,以及键值对。 注意:hive表中必须有字段key作为主键

CREATE TABLE grzx_common(key string, account_status string, balance string)    

STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'  

WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:account_status,info:balance")   

TBLPROPERTIES ("hbase.table.name" = "grzx_common");

hive中查看表desc grzx_common;

hbase中查看表describe "grzx_common"

hive中insert数据insert into table grzx_common select 'F1234','2','50000' from dual;

hbase中查看结果: get 'grzx_common','F1234'

hbase中修改数据:put 'grzx_common','F1234','info:balance','60000'

hive中查看结果: select * from grzx_common

猜你喜欢

转载自zzhonghe.iteye.com/blog/2267375