如何在hbase shell中获取旧值

时间:2015-04-02 15:15:55

标签: hadoop hbase

    hbase(main):004:0> create 'htable','cf'
0 row(s) in 0.4790 seconds

=> Hbase::Table - htable
hbase(main):005:0> alter 'htable', NAME => 'id', VERSIONS => 100
Updating all regions with the new schema...
0/1 regions updated.
1/1 regions updated.
Done.
0 row(s) in 2.2790 seconds

hbase(main):006:0> put 'htable','row1','cf:id',2
0 row(s) in 0.1560 seconds

hbase(main):007:0> put 'htable','row1','cf:id',4
0 row(s) in 0.0080 seconds

hbase(main):008:0> get 'htable', 'row1', {COLUMN => 'cf:id', VERSIONS => 4}
COLUMN                CELL                                                      
 cf:id                timestamp=1428041368763, value=4                          
1 row(s) in 0.0200 seconds

我通过设置VERSIONS =>来改变了表格。 100,但是 每次它都会给出最新的记录。如何获得旧的价值?是否有任何添加命令或设置需求?

1 个答案:

答案 0 :(得分:1)

在hbase shell中试试这个:

disable 'htable'

drop 'htable'

create 'htable',NAME=>'cf',VERSIONS=>100

put 'htable','row1','cf:id',1

scan 'htable'

put 'htable','row1','cf:id',2

scan 'htable'

put 'htable','row1','cf:id',3

scan 'htable'

put 'htable','row1','cf:id',4

scan 'htable'

get 'htable', 'row1', {COLUMN => 'cf:id', VERSIONS => 4}

Scan命令用于验证和匹配时间戳。

相关问题