操作步骤:
本案例hbase一张表三个列簇,对应hive中三张表。
表的格式如下:
student
id int,
name string,
gender string,
age int
class
id int,
name string
score
id int,
scores int
首先现在hbase中新建一张表,create 'wan:student_info','stu','cls','score'
。
然后在hive中,依次创建三张表。
student表
create external table if not exists student(
id int,
name string,
gender string,
age int
)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties
("hbase.columns.mapping"=":key,stu:name,stu:gender,stu:age")
tblproperties("hbase.table.name"="wan:student_info")
class表
create external table if not exists class(
id int,
name string
)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties
("hbase.columns.mapping"=":key,cls:name")
tblproperties("hbase.table.name"="wan:student_info")
score表
create external table if not exists score(
id int,
scores int
)
stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
with serdeproperties
("hbase.columns.mapping"=":key,score:scores")
tblproperties("hbase.table.name"="wan:student_info")
插入数据:
student表:
insert into student values (1,'zhangsan','male',21);
class表:
insert into class values(1,'dayi');
score表:
insert into score values(1,90);
使用命令scan 'wan:student_info'
来扫描全表