yxysuanfa

[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\'



分类:

技术点:

相关文章: