创建hive整合hbase的表总结

来源:互联网 发布:数据爆炸 2017 时代 编辑:程序博客网 时间:2024/05/12 00:37

[Author]: kwu 

创建hive整合hbase的表总结,如下两种方式:

1、创建hive表的同步创建hbase的表

CREATE  TABLE stage.hbase_news_company_content(key string comment "流水号",news_id string comment "新闻id",news_content string comment "文章内容")   STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'   WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:news_id,cf1:news_content")   TBLPROPERTIES("hbase.table.name" = "news_company_content");

这种方式创建hive表,删除hive的表,hbase的表的数据也会被删除


2、外表创建hive表整合hbase的表

需要先创建hbase的表:

create 'jsActionPage','cf1'

创建hive的外表

CREATE EXTERNAL TABLE ods.hbase_jsActionPage(key string, bdcCookieId string ,pcScreenRatio string ,pageCloseTime string ,pageLoadCompleteTime string,pageOpenTime string,currentURL string)   STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'   WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:bdcCookieId,cf1:pcScreenRatio,cf1:pageCloseTime,cf1:pageLoadCompleteTime,cf1:pageOpenTime,cf1:currentURL")   TBLPROPERTIES("hbase.table.name" = "jsActionPage"); 

3、如果往hive整合hbase的表中插入数据

SQL方式:

insert into stage.hbase_news_company_content select a,b,c from stage.tracklog limit 15;


hbase命令

put 'jsActionPage','row1','cf1:time','20150818'



1 0
原创粉丝点击