介绍

Apache Phoenix enables OLTP and operational analytics in Hadoop for low latency applications by combining the best of both worlds:

  • the power of standard SQL and JDBC APIs with full ACID transaction capabilities and
  • the flexibility of late-bound, schema-on-read capabilities from the NoSQL world by leveraging HBase as its backing store

Apache Phoenix is fully integrated with other Hadoop products such as Spark, Hive, Pig, Flume, and Map Reduce.

shell

./sqlline.py zk1,zk2,zk3
!quit
!tables
!describe table_name
!outputformat vertical
ROWKEY           00001f6750f9
PT               20171221
c1               3711075160
c2               767742
c3               2
c4               136
c5               2
c5               2
c7               3

基本语法


CREATE TABLE IF NOT EXISTS  table_name 
(ROWKEY VARCHAR, PT VARCHAR,c1 UNSIGNED_LONG, 
c2  UNSIGNED_LONG,c3 UNSIGNED_LONG,c4 UNSIGNED_LONG,c5 UNSIGNED_LONG,
 CONSTRAINT my_pk PRIMARY KEY (ROWKEY))COLUMN_ENCODED_BYTES=NONE;
ALTER TABLE table_name ADD c7 UNSIGNED_LONG,c8 UNSIGNED_LONG
drop table table_name;
create index column_index on test (c1);

这样只会在查询c1是生效,即select c1 from table_name where c1 = '1'时才生效,对于select * from table_name where c1 = '1'则必须添加覆盖索引:

create index cdd_pt_sort_index on table_name (c1,c2 desc) INCLUDE(c1,c2,c3,c4
 );

drop index cdd_pt_sort_index on table_name

其他