复制代码
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42hive 创建内部表 时 同时自动创建Hbase表,删除Hive内部表时,也会自动删除hbase表 CREATE TABLE student_hive_hbase( id int, name string, age int, height int) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:name,cf1:age,cf1:height") TBLPROPERTIES ("hbase.table.name" = "student_hive_hbase"); 注意:key 默认是第一个字段(id) 此时hive表与hbase表都建立了 从已有Hive表student导数据到student_hive_hbase表 insert into student_hive_hbase select*from student; 查看student_hive_hbase表是否有数据 select * from student_hive_hbase; 查看hbase student_hive_hbase 是否有数据 hbase(main):003:0> scan 'student_hive_hbase' ROW COLUMN+CELL 1 column=cf1:age, timestamp=1540522220850, value=21 1 column=cf1:height, timestamp=1540522220850, value=80 1 column=cf1:name, timestamp=1540522220850, value=zhangsan Hive 建外部表 (需要在hbase手动执行建表语句),好处是 删除hive中的student_hive_hbase表时 不会自动删除hbase 中的student_hive_hbase表。 create 'student_hive_hbase', 'cf1' CREATE EXTERNAL TABLE student_hive_hbase( id int, name string, age int, height int) STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler' WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,cf1:name,cf1:age,cf1:height") TBLPROPERTIES ("hbase.table.name" = "student_hive_hbase");
最后
以上就是高大发箍最近收集整理的关于hive 创建(内外部)表 时 同时创建Hbase表的全部内容,更多相关hive内容请搜索靠谱客的其他文章。
本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
发表评论 取消回复