HBase简单QL语句描述

时间:2021-09-04 08:24:37

1.进入HBase

hbase shell

2.创建表

hbase(main):016:0> create 'test','c1','c2'  #创建的时候不用写ROW KEY

3.插入数据

hbase(main):017:0> put 'test','r1','c1:1','value1-1/1'
hbase(main):018:0> put 'test','r1','c1:2','value1-1/2'
hbase(main):019:0> put 'test','r1','c1:3','value1-1/3'
hbase(main):020:0> put 'test','r1','c2:1','value1-2/1'
hbase(main):021:0> put 'test','r1','c2:2','value1-2/2'
hbase(main):022:0> put 'test','r2','c1:1','value2-1/1'
hbase(main):023:0> put 'test','r2','c2:1','value2-2/1'

4.查询数据

hbase(main):024:0> scan 'test'
输出如下:

ROW                   COLUMN+CELL
 r1                   column=c1:1, timestamp=1429691705101, value=value1-1/1
 r1                   column=c1:2, timestamp=1429691782462, value=value1-1/2
 r1                   column=c1:3, timestamp=1429691787094, value=value1-1/3
 r1                   column=c2:1, timestamp=1429691827124, value=value1-2/1
 r1                   column=c2:2, timestamp=1429691839687, value=value1-2/2
 r2                   column=c1:1, timestamp=1429691857863, value=value2-1/1
 r2                   column=c2:1, timestamp=1429691875470, value=value2-2/1
2 row(s) in 0.0230 seconds


5.查询其中一定的数据

hbase(main):025:0> get 'test','r1',{COLUMN=>'c2:2'}
输出如下:

COLUMN                CELL
 c2:2                 timestamp=1429691839687, value=value1-2/2
1 row(s) in 0.0190 seconds


全文完。转载请注明出处: http://blog.csdn.net/ghuil/article/details/45586735