HBase0.96.x開發使用(二) -- hbase shell命令

hbase shell命令shell

一、進入hbase shell環境:oop

[hbase@hadoop230 ~]$ ./hbase shell.net

HBase Shell; enter 'help<RETURN>' for list of supported commands.blog

Type "exit<RETURN>" to leave the HBase Shellhadoop

Version 0.96.0-hadoop1, r1531434, Fri Oct 11 15:11:29 PDT 2013get


二、查找幫助it

hbase(main):003:0> help         列表全部幫助信息io

hbase(main):069:0> help 'alter' 列出指定命令的幫助信息test


三、建立表,建立一個名爲 test 的表,這個表只有一個列族爲cf,建立表的時候不須要建立列族。能夠列出全部的表來檢查建立狀況,而後插入些值。配置

hbase(main):003:0>create 'test', 'cf';


四、列出全部表

hbase(main):087:0> list

TABLE                                                                                                                                 

test                                                                                                                                  

1 row(s) in 0.0320 seconds


五、查看錶是否存在

hbase(main):088:0> exists 'test'

Table test does exist                                                                                                                 

0 row(s) in 0.0630 seconds


六、查看錶結構

hbase(main):090:0> describe 'test'


七、添加數據、修改數據操做命令是同樣的

添加數據:put '表名','主健','列簇.限定名','值'

hbase(main):004:0> put 'test', 'row1', 'cf:a', 'value1'

0 row(s) in 0.0560 seconds

hbase(main):005:0> put 'test', 'row1', 'cf:b', 'value2'

0 row(s) in 0.0370 seconds

hbase(main):006:0> put 'test', 'row1', 'cf:c', 'value3'

0 row(s) in 0.0450 seconds


八、修改表結構,從0.92.x開始能夠在線修改表結構,須要配置hbase.online.schema.update.enable,默認false;當配置false時,須要先禁用表,再啓用;

hbase(main):091:0> disable 'test'       禁用表

hbase(main):092:0> alter 'test','cf2'   加入列簇         

hbase(main):093:0> enable 'test'        啓用表


九、掃描表數據

hbase(main):105:0> scan 'test'


十、查找數據

hbase(main):150:0> get 'test','row1'  查找指定行的全部列

COLUMN                             CELL                                                                                               

 cf:a                              timestamp=1386321878650, value=value1                                                                    

 cf:b                              timestamp=1386322192816, value=value2                                                         

 cf:c                              timestamp=1386322197235, value=value3


hbase(main):151:0> get 'test','row1','cf:a' 查找指定行指定列

COLUMN                             CELL                                                                                               

 cf:a                              timestamp=1386322197235, value=value1

 

十一、刪除整行數據

hbase(main):169:0> deleteall 'test','row1'


十二、刪除列數據,注意:當全部的列都清空時,該行也會被刪除

hbase(main):160:0> delete 'test', 'row1','cf:a'

 

十一、刪除表,刪除表以前先要禁用表

hbase(main):117:0> drop 'test'


十二、查看總記錄數

hbase(main):142:0> count 'test'


1三、查看錶是否可用

hbase(main):143:0> is_enabled 'test'


1四、建立增量,列"cf:d"不須要預先建立

hbase(main):012:0> incr 'test','row2','cf:d',0

COUNTER VALUE = 0


hbase(main):013:0> incr 'test','row1','cf:d',1

COUNTER VALUE = 1


hbase(main):014:0> incr 'test','row1','cf:d',2

COUNTER VALUE = 3


hbase(main):015:0> incr 'test','row1','cf:d',3

COUNTER VALUE = 6


hbase(main):133:0> get_counter 'test','row1','cf:d',3   獲取當前值,這裏應該存在BUG,get_counter不該該須要第4個參數的,如今須要隨意給它一個參數;

COUNTER VALUE = 6


原文出處: http://my.oschina.net/u/158197/blog/189263 (原創文章,轉載請註明出處)

相關文章
相關標籤/搜索