关于hbase二级索引的描述 hbase的二级索引应用( 二 )


2. Phoenix 中创建与 namespace 名称一致的 schema
0: jdbc:phoenix:> create schema if not exists "ns1000";No rows affected (0.012 seconds)(可左右滑动)
3. Phoenix 中创建视图,并查询数据及条数
0: jdbc:phoenix:> use "ns1000";No rows affected (0.021 seconds)0: jdbc:phoenix:> create view "operate_log"(. . . . . . . . > "pk" varchar primary key,. . . . . . . . > "f"."appVersion" varchar,. . . . . . . . > "f"."city" varchar,. . . . . . . . > "f"."lat" varchar,. . . . . . . . > "f"."lon" varchar,. . . . . . . . > "f"."memberType" varchar,. . . . . . . . > "f"."time" varchar);No rows affected (6.555 seconds)0: jdbc:phoenix:> !tables+------------+--------------+--------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------------+---------------+---------------+-----------------+------------+--------+| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | TABLE_TYPE | REMARKS | TYPE_NAME | SELF_REFERENCING_COL_NAME | REF_GENERATION | INDEX_STATE | IMMUTABLE_ROWS | SALT_BUCKETS | MULTI_TENANT | VIEW_STATEMENT | VIEW_TYPE | INDEX_ |+------------+--------------+--------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------------+---------------+---------------+-----------------+------------+--------+| | SYSTEM | CATALOG | SYSTEM TABLE | | | | | | false | | false | | | || | SYSTEM | FUNCTION | SYSTEM TABLE | | | | | | false | | false | | | || | SYSTEM | LOG | SYSTEM TABLE | | | | | | true | 32 | false | | | || | SYSTEM | SEQUENCE | SYSTEM TABLE | | | | | | false | | false | | | || | SYSTEM | STATS | SYSTEM TABLE | | | | | | false | | false | | | || | ns1000 | operate_log | VIEW | | | | | | false | | false | | MAPPED | |+------------+--------------+--------------+---------------+----------+------------+----------------------------+-----------------+--------------+-----------------+---------------+---------------+-----------------+------------+--------+0: jdbc:phoenix:> !columns "operate_log";+------------+--------------+--------------+--------------+------------+------------+--------------+----------------+-----------------+-----------------+-----------+----------+-------------+----------------+-------------------+--------+| TABLE_CAT | TABLE_SCHEM | TABLE_NAME | COLUMN_NAME | DATA_TYPE | TYPE_NAME | COLUMN_SIZE | BUFFER_LENGTH | DECIMAL_DIGITS | NUM_PREC_RADIX | ABLE | REMARKS | COLUMN_DEF | SQL_DATA_TYPE | SQL_DATETIME_SUB | CHAR_O |+------------+--------------+--------------+--------------+------------+------------+--------------+----------------+-----------------+-----------------+-----------+----------+-------------+----------------+-------------------+--------+| | ns1000 | operate_log | pk | 12 | VARCHAR | | | | | 0 | | | | | || | ns1000 | operate_log | appVersion | 12 | VARCHAR | | | | | 1 | | | | | || | ns1000 | operate_log | city | 12 | VARCHAR | | | | | 1 | | | | | || | ns1000 | operate_log | lat | 12 | VARCHAR | | | | | 1 | | | | | || | ns1000 | operate_log | lon | 12 | VARCHAR | | | | | 1 | | | | | || | ns1000 | operate_log | memberType | 12 | VARCHAR | | | | | 1 | | | | | || | ns1000 | operate_log | time | 12 | VARCHAR | | | | | 1 | | | | | |+------------+--------------+--------------+--------------+------------+------------+--------------+----------------+-----------------+-----------------+-----------+----------+-------------+----------------+-------------------+--------+0: jdbc:phoenix:> select * from "operate_log" limit 1;+------------------------+-------------+-------+---------------------+---------------------+-------------+----------------+| pk | appVersion | city | lat | lon | memberType | time |+------------------------+-------------+-------+---------------------+---------------------+-------------+----------------+1538216707720 | 2.22.0 | 重庆市 | 29.577587127685547 | 106.50493621826172 | 0 | 1538216707720 |+------------------------+-------------+-------+---------------------+---------------------+-------------+----------------+1 row selected (0.115 seconds)0: jdbc:phoenix:> select count(*) from "operate_log";+-----------+| COUNT(1) |+-----------+| 2799827 |+-----------+1 row selected (3.848 seconds)(可左右滑动)


以上关于本文的内容,仅作参考!温馨提示:如遇健康、疾病相关的问题,请您及时就医或请专业人士给予相关指导!

「四川龙网」www.sichuanlong.com小编还为您精选了以下内容,希望对您有所帮助: