1:创建表

create 'MY_TABLE', 'CF1','CF2'

2:在hbase上插入一条数据

put 'MY_TABLE','' ,'CF1:V1', 'uwo1'

3:在phoenix上创建视图

create view MY_TABLE (PK  varchar primary key, CF1.V1 varchar, CF2.V2 varchar, CF1.V3 varchar);

4:查询phoenix的视图

: jdbc:phoenix:df1:> select * from MY_TABLE;
+-----+-------+-----+-----+
| PK | V1 | V2 | V3 |
+-----+-------+-----+-----+
| | uwo1 | | |
+-----+-------+-----+-----+

5:向hbase在插入一条数据

put 'MY_TABLE','' ,'CF1:V3', ''

此时hbase中有2条数据,然后再次插入phoenix的视图:

: jdbc:phoenix:df1:> select * from MY_TABLE;
+-----+-------+-----+-----+
| PK | V1 | V2 | V3 |
+-----+-------+-----+-----+
| | uwo1 | | |
+-----+-------+-----+-----+
row selected (0.018 seconds)

仍然只有1条数据。说明:phoenix构建hbase视图,更新hbase表后,视图表是不会更新的

05-11 17:01