創建hive整合hbase的表總結


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




免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM