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;

 

版权声明:本文为chenzechao原创文章,遵循 CC 4.0 BY-SA 版权协议,转载请附上原文出处链接和本声明。
本文链接:https://www.cnblogs.com/chenzechao/p/8624031.html