1.启动hiveserver2,
beeline>!connect jdbc:hive2://localhost:10000,默认用户名为当前用户名
2.建立关系表
create table t_student(id int ,name string) stored by
'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with
serdeproperties("hbase.columns.mapping"=":key,st1:name")
tblproperties("hbase.table.name"="t_student","hbase.mapred.output.outputtable" = "t_student");
###"hbase.mapred.output.outputtable" = "t_student"这个可以不要,表数据就存储在"hbase.table.name"="t_student"表中了) 。
创建外部表:
create external table t_student_info(id int,age int,sex string) stored by 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' with serdeproperties("hbase.columns.mapping"=":key,st1:age,st2:sex") tblproperties("hbase.table.name"="t_student_info");
关联查询(通过mr处理时间较久)
hive>select * from t_student t join t_student_info ti where t.id=ti.id;