hive与hbase关联

 

 1 进入hbase: hbase shell
 2 进入HIVE: hive
 3 
 4 hbase中建一张t_student_info表,添加两个列族
 5 create 't_student_info','st1','st2'
 6 
 7 hbase查看表结构
 8 describe 't_student_info'
 9 
10 
11 
12 hive 创建外部表要使用EXTERNAL 关键字
13 create external table t_student_info(
14      id int
15     ,age int
16     ,sex string
17 ) 
18 stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' 
19 with serdeproperties("hbase.columns.mapping"=":key,st1:age,st2:sex") 
20 tblproperties("hbase.table.name"="t_student_info")
21 ;
22 
23 
24 hbase t_student_info 中添加数据
25 put 't_student_info','1001','st2:sex','man'
26 put 't_student_info','1001','st1:age','20'
27 put 't_student_info','1002','st1:age','18'
28 put 't_student_info','1002','st2:sex','woman'
29 
30 hive 数据查询
31 select * from t_student_info;

 

posted @ 2018-03-22 15:14  chenzechao  阅读(392)  评论(0编辑  收藏  举报