1. Create a HBase table
create 'hbase_test','user'
2. Insert Data
put 'hbase_test','111','user:name','jack'
put 'hbase_test','111','user:age','18'
View HBase
3. Create external Hive table associated Hbase
create external table hbase_test1(
id int,
name string,
age int
)
STORED BY 'org.apache.hadoop.hive.hbase.HBaseStorageHandler'
WITH SERDEPROPERTIES ("hbase.columns.mapping" = ":key,user:name,user:age")
TBLPROPERTIES("hbase.table.name" = "hbase_test");
View Hive
4. The insert data into HBase, for verification
Hive query
The Hive inserted into the data table, for verification
insert into hbase_test(id,name,age) values(333,'mary',25);
Hive query
query HBase
6. create the same table in Phoenix to achieve with HBase table mapping
create table if not exists "hbase_test"(id varchar primary key, "user"."name" varchar, "user"."age" varchar);
note:
- Phoneix created HBase table and mapped to the same table
- Create a table of phoneix field names and field names in the mapping table HBase to the same (note the capitalization)
Phoenix inquiry
7. The data inserted into the Phoenix, for verification
upsert into "hbase_test"(id,"name","age") values('444','haha','33');
Phoenix query
query HBase
query Hive