赞
踩
创建hbase表只有一个info列族
hbase(main):003:0> create 'smart_test:test_user','info'
0 row(s) in 1.4330 seconds
=> Hbase::Table - smart_test:test_user
在列族下面添加name和age列以及列数据
hbase(main):005:0> put 'smart_test:test_user',1,'info:name','赵'
0 row(s) in 0.2800 seconds
hbase(main):006:0> put 'smart_test:test_user',1,'info:age',18
0 row(s) in 0.0170 seconds
表数据据预览
hbase(main):007:0> scan 'smart_test:test_user'
ROW COLUMN+CELL 1 column=info:age, timestamp=1655170432817, value=18 1 column=info:name, timestamp=1655170422168, value=\xE8\xB5\xB5
CREATE EXTERNAL TABLE
test_user
(
id string COMMENT 'hbase rowkey',
name string COMMENT '姓名',
age string COMMENT '年龄'
)
STORED BY "org.apache.hadoop.hive.hbase.HBaseStorageHandler"
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,info:name,info:age")
TBLPROPERTIES("hbase.table.name" = "smart_test:test_user");
hive> select * from test_user;
OK
1 赵 18
hive> insert into table test_user select 2, '钱', 12 union all select 3, '孙', 19;
hbase(main):008:0> scan 'smart_test:test_user'
ROW COLUMN+CELL
1 column=info:age, timestamp=1655170432817, value=18
1 column=info:name, timestamp=1655170422168, value=\xE8\xB5\xB5
2 column=info:age, timestamp=1655171127474, value=12
2 column=info:name, timestamp=1655171127474, value=\xE9\x92\xB1
3 column=info:age, timestamp=1655171127474, value=199
3 column=info:name, timestamp=1655171127474, value=\xE5\xAD\x99
3 row(s) in 0.0350 seconds
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。