Hbase - 常用命令

襲冷發表於2015-01-11
status 命令
hbase(main):002:0> status
8 servers, 0 dead, 45.2500 average load
version 命令
hbase(main):003:0> version
0.96.0-hadoop2-gphd-3.0.1.0, r40412e, Mon Apr 14 12:09:37 CST 2014
create 命令
    建立一個名為 Student 的表,這個表有兩個列族為 info 和 score。其中表名、列族都要用單引號括起來

hbase(main):001:0> create 'Student','info','score'
0 row(s) in 2.0840 seconds
list 命令
    列出所有的表

hbase(main):002:0> list
TABLE   
 Test    
1 row(s) in 0.0940 seconds
put 命令
    向表中插入資料,格式: put 表名,行名,列名([列族:列名]),值

hbase(main):003:0> put 'Student','2014_SW02_25','info:name','tom'
0 row(s) in 0.1060 seconds
scan 命令

    檢視錶中的所有資料

hbase(main):012:0> scan 'Student'
ROW                                        COLUMN+CELL  
 2014_SW02_18                              column=info:name, timestamp=1417013170521, value=jack  
 2014_SW02_25                              column=info:age, timestamp=1417012953351, value=23     
 2014_SW02_25                              column=info:name, timestamp=1417012947503, value=tom   
 2014_SW02_25                              column=score:math, timestamp=1417012957492, value=95   
2 row(s) in 0.0220 seconds

get 命令
    檢視錶中指定的資料
        指定行

hbase(main):007:0> get 'Student','2014_SW02_25'
COLUMN                                     CELL       
 info:age                                  timestamp=1417012953351, value=23  
 info:name                                 timestamp=1417012947503, value=tom 
 score:math                                timestamp=1417012957492, value=95 
 3 row(s) in 0.0210 seconds
        指定行和列族
hbase(main):008:0> get 'Student','2014_SW02_25','info'
COLUMN                                     CELL                                        
 info:age                                  timestamp=1417012953351, value=23                          
 info:name                                 timestamp=1417012947503, value=tom                 
2 row(s) in 0.0180 seconds
        指定行、列族和列
hbase(main):009:0> get 'Student','2014_SW02_25','info:name'
COLUMN                                     CELL    
 info:name                                 timestamp=1417012947503, value=tom     
1 row(s) in 0.0200 seconds
        指定行的字首和記錄數
hbase(main):041:0> scan 'Student',{LIMIT => 2, STARTROW => '2014_AC01'} 
        指定入庫時間區間查詢
scan 'Student',{LIMIT => 2, TIMERANGE => [1417006187875, 1417007274669]}
count 命令
    統計表中有多少條記錄

hbase(main):013:0> count 'Student'
2 row(s) in 0.0120 seconds
exists 命令
hbase(main):014:0> exists 'Student'
Table Student does exist              
0 row(s) in 0.0380 seconds
delete 命令
hbase(main):015:0> delete 'Student','2014_SW02_25','info:age'
0 row(s) in 0.0780 seconds
truncate 命令
    重建表(先刪除)

hbase(main):029:0> truncate 'Student'
Truncating 'Student' table (it may take a while):
 - Disabling table...
 - Dropping table...
 - Creating table...
0 row(s) in 1.9420 seconds
disable 、drop 命令
    遮蔽表和刪除表

hbase(main):032:0> disable 'Student'
0 row(s) in 1.3510 seconds

hbase(main):035:0> drop 'Student'
0 row(s) in 0.2380 seconds
 

 

 

相關文章