hbase(main)
:079:0> create 'scores'
,0 row(s)
in 0.9590 seconds
hbase(main)
:080:0> put 'scores'
,'tom'
,'course:math'
,'97'
0 row(s)
in 0.0100 seconds
hbase(main)
:081:0> scan 'scores'
row column+cell
tom column=course:math, timestamp=1394097631387, value=97
1 row(s)
in 0.0190 seconds
hbase(main)
:082:0> put 'scores'
,'tom'
,'course:math'
,'100'
0 row(s)
in 0.0080 seconds
hbase(main)
:026:0> scan 'scores'
row column+cell
tom column=course:math, timestamp=1394097651029, value=100
1 row(s)
in 0.0110 seconds
hbase(main)
:027:0> scan 'scores'
,row column+cell
tom column=course:math, timestamp=1394097631387, value=97
1 row(s)
in 0.0210 seconds
hbase(main)
:028:0> scan 'scores'
,row column+cell
tom column=course:math, timestamp=1394097651029, value=100
1 row(s)
in 0.0100 seconds
從上面可以看到,hbase預設scan出來的結果是最後一條時間戳的記錄,那麼如何把這兩條都scan出來呢,
這時候可以加入versions這個約束條件:
hbase(main)
:032:0> scan 'scores'
,row column+cell
tom column=course:math, timestamp=1394097651029, value=100
tom column=course:math, timestamp=1394097631387, value=97
1 row(s)
in 0.0130 seconds
上面的命令,已經把這條記錄都scan出來了。
scan 'scores'
,row column+cell
tom column=course:math, timestamp=1394097631387, value=97
1 row(s)
in 0.0130 seconds
從上面的結果只scan出一條記錄。可知,timerange表示的是」>=開始時間 and 《結束時間「的。再看:
hbase(main)
:003:0> scan 'scores'
,row column+cell
tom column=course:math, timestamp=1394097651029, value=100
tom column=course:math, timestamp=1394097631387, value=97
1 row(s)
in 0.0100 seconds
ok,這樣就明白了
。不過上面的加了versions=>2,就可以查到歷史的資料了,但是必須再建立表的時候加上versions,否則無效,看下面的例子:
hbase(main)
:082:0> create 'member'
,'address'
,'info'
0 row(s)
in 0.4140 seconds
=> hbase:
:table - member
hbase(main)
:093:0> put 'member'
,'wanglei'
,'info:age'
,'24'
0 row(s)
in 0.0730 seconds
hbase
(main):
093:
1>get 'member'
,'wanglei'
,column cell
info:age timestamp=1394438746187, value=24
hbase
(main):
093:
7>
put
'member'
,'wanglei'
,'info:age'
,'99'
0 row(s
)in0.
0730 seconds
hbase
(main):
093:
18>
get
'member'
,'wanglei'
,column cell
info:age timestamp=1394439539837, value=100
hbase(main)
:022:0> get 'member'
,'wanglei'
,column cell
info:age imestamp=1394439539837, value=100
1 row(s)
in 0.0050 seconds
可以看到,雖然加了versions,但get的結果是1條;這就是因為建表時預設的version是1.
修改versions:
hbase(main)
:029:0> alter 'member'
,updating all regions with the new schema...
0/1 regions updated.
1/1 regions updated.
done.
0 row(s)
in 2.1680 seconds
hbase(main)
:046:0> put 'member'
,'wanglei'
,'info:age'
,'101'
0 row(s)
in 0.0590 seconds
hbase(main)
:047:0> get 'member'
,'wanglei'
,column cell
info:age timestamp=1394441161595, value=101
1 row(s)
in 0.0120 seconds
那麼現在就可以把倆條記錄get出來了,如下:
hbase(main)
:049:0> get 'member'
,'wanglei'
,column cell
info:age timestamp=1394441161595, value=101
info:age timestamp=1394439539837, value=100
2 row(s)
in 0.0080 seconds
HBase 常用Shell命令
1.檢視hbase中存在的所有表 list hbase main list2.建立新的表 create 使用create命令來建立乙個新的表。在建立的時候,必須指定表名和列族名 hbase中的表至少有乙個列族 create hbase main create test 3.檢視表結構 describ...
HBASE 常用shell命令
1 建立表和列族 create student info address 2 向表中插入資料 put student 1 info age 20 put student 1 info name wang put student 1 info class 1 put student 1 address...
HBase常用shell命令
在hbase的根目錄下 bin hbase shell 如果配置了環境變數 hbase shellhbase main 001 0 helplist建立user表 包含info data兩個列族 create user info data 或者create user 向user表中插入資訊,row ...