================ 目录 ================
基本
删除
插入
查寻
更新
通过指定时间戳来获取数据
全表扫描
清空表
====================================
- 基本。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
##进入shell
>>hbase shell
##查看状态
>>status
##查看版本
>>version
##创建表 表名: member; 列族: member_id ,address, infor
>>create 'member','member_id','address','info'
##查看所有表
>>list
##查看表的信息
>>descripe 'member'
- 删除。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
##删除列族‘member_id’
>>alter 'member',{NAME=>'member_id',METHOD=>'delete'}
#####出错:ERROR: org.apache.hadoop.hbase.TableNotDisabledException:
#####先要将table进行disable操作(离线)
>>disable 'member'
>>alter 'member',{NAME=>'member_id',METHOD=>'delete'}
#####重新让表可用enable(在线)
>>enable 'member'
##删除表
>>disable ‘member’
>>drop 'member'
##查看表是否存在
>>exists 'member'
##查看表是否enable(在线)
>>is_enabled 'member'
##查看表是否disable(离线)
>>is_disabled 'member'
##
删除指定行键的字段
>>delete 'member','201401','info:age'
>>get 'member','201401','info'
-----------------------------------------------------------------------------
hbase(main):017:0> delete 'member','201401','info:age'
0 row(s) in 0.0080 seconds
hbase(main):018:0> get 'member','201401','info'
COLUMN CELL
info:birthday timestamp=1415240002266, value=1987-06-17
info:company timestamp=1415240043955, value=alibaba
2 row(s) in 0.0420 seconds
-----------------------------------------------------------------------------
##
删除整行
>>
deleteall 'member','201401'
>>get 'member','201401'
-----------------------------------------------------------------------------
hbase(main):023:0> deleteall 'member','201401'
0 row(s) in 0.0150 seconds
hbase(main):024:0> get 'member','201401'
COLUMN CELL
0 row(s) in 0.0200 seconds
-----------------------------------------------------------------------------
- 插入。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
##插入数据
## ‘member’: 表名;
## ‘201401’: 行键;
## 'info.age': 指定列族info中age列;
## ‘24’: 值
>>put 'member','201401','info:age','24'
>>put 'member','201401','info:age','25'
>>put 'member','201401','info:birthday','1987-06-17'
>>put 'member','201401','info:company','alibaba'
>>put 'member','201401','address:contry','china'
>>put 'member','201401','address:province','zhejiang'
>>put 'member','201401','address:city','hangzhou'
>>put 'member','201402','info:birthady','1991-09-12'
>>put 'member','201402''info:favorite','moive'
>>put 'member','201402','info:company','alibaba'
>>put 'member','201402','address:contry','china'
>>put 'member','201402','address:province','jiangxi'
>>put 'member','address:city','shangrao'
>>put 'member','201402','address:city','shangrao'
>>put 'member','201402','address:town','yushan'
- 查寻。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
##查寻表有多少行
>>count 'member'
##查寻数据
####按照
行键查寻
>>get 'member','201401'
-----------------------------------------------------------------------------
hbase(main):049:0> get 'member','201401'
COLUMN CELL
address:city timestamp=1415240104894, value=hangzhou
address:contry timestamp=1415240065717, value=china
address:province timestamp=1415240088114, value=zhejiang
info:age timestamp=1415239798585, value=25
info:birthday timestamp=1415240002266, value=1987-06-17
info:company timestamp=1415240043955, value=alibaba
6 row(s) in 0.0570 seconds
-----------------------------------------------------------------------------
####按照
行键+列族查寻
>>get 'member','201401','info'
-----------------------------------------------------------------------------
hbase(main):001:0> get 'member','201401','info'
COLUMN CELL
info:age timestamp=1415239798585, value=25
info:birthday timestamp=1415240002266, value=1987-06-17
info:company timestamp=1415240043955, value=alibaba
3 row(s) in 1.7860 seconds
-----------------------------------------------------------------------------
####按照
行键+列族+列查寻
>>get 'member','201401','info:age'
-----------------------------------------------------------------------------
hbase(main):004:0> get 'member','201401','info:age'
COLUMN CELL
info:age timestamp=1415239798585, value=25
1 row(s) in 0.0100 seconds
-----------------------------------------------------------------------------
- 更新。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。。
>>put 'member','201401','info:age','40'
>>get 'member','201401','info:age'
-----------------------------------------------------------------------------
hbase(main):007:0> put 'member','201401','info:age','40'
0 row(s) in 0.0090 seconds
hbase(main):008:0> get 'member','201401','info:age'
COLUMN CELL
info:age timestamp=1415240971567, value=40
1 row(s) in 0.0080 seconds
-----------------------------------------------------------------------------
- 通过指定时间戳来获取数据。。。。。。。。。。。。。。。。。。。。。。。
##通过指定timestamp来获取数据
>>get 'member','201401',{COLUMN=>'info:age', TIMESTAMP=>1415240971567}
>>get 'member','201401',{COLUMN=>'info:age', TIMESTAMP=>1415239798585}
-----------------------------------------------------------------------------
hbase(main):010:0> get 'member','201401',{COLUMN=>'info:age', TIMESTAMP=>1415240971567}
COLUMN CELL
info:age timestamp=1415240971567, value=40
1 row(s) in 0.0080 seconds
hbase(main):011:0> get 'member','201401',{COLUMN=>'info:age', TIMESTAMP=>1415239798585}
COLUMN CELL
info:age timestamp=1415239798585, value=25
1 row(s) in 0.0230 seconds
-----------------------------------------------------------------------------
>>scan 'member'
-----------------------------------------------------------------------------
hbase(main):012:0> scan 'member'
ROW COLUMN+CELL
201401 column=address:city, timestamp=1415240104894, value=hangzhou
201401 column=address:contry, timestamp=1415240065717, value=china
201401 column=address:province, timestamp=1415240088114, value=zhejiang
201401 column=info:age, timestamp=1415240971567, value=40
201401 column=info:birthday, timestamp=1415240002266, value=1987-06-17
201401 column=info:company, timestamp=1415240043955, value=alibaba
201402 column=address:city, timestamp=1415240308521, value=shangrao
201402 column=address:contry, timestamp=1415240248719, value=china
201402 column=address:province, timestamp=1415240275045, value=jiangxi
201402 column=address:town, timestamp=1415240332693, value=yushan
201402 column=info:birthady, timestamp=1415240155033, value=1991-09-12
201402 column=info:company, timestamp=1415240227088, value=alibaba
201402 column=info:favorite, timestamp=1415240199487, value=moive
2 row(s) in 0.0990 seconds
-----------------------------------------------------------------------------
>>truncate 'member'
-----------------------------------------------------------------------------
hbase(main):028:0> truncate 'member'
Truncating 'member' table (it may take a while):
-
Disabling table...
-
Dropping table...
-
Creating table...
0 row(s) in 3.4000 seconds
-----------------------------------------------------------------------------