nfo:age'
COLUMN CELL
info:age timestamp=1434253975698,value=24
1 row(s) in0.0440 seconds
?
f) 更新记录
命令put
hbase(main):067:0>get'member','xiaoming','info:age'
COLUMN CELL
info:age timestamp=1434253975698,value=24
1 row(s) in0.0440 seconds
?
hbase(main):068:0>put'member','xueba','info:age','26'
0 row(s) in0.1000 seconds
?
hbase(main):069:0>get 'member','xueba','info:age'
COLUMN CELL
info:age timestamp=1434254477087,value=26
1 row(s) in0.0410 seconds
上面get查看的是新的数据,如果想查看老的数据,执行:
通过timestamp来获取数据
hbase(main):070:0>get'member','xueba',{COLUMN => 'info:age', TIMESTAMP => 1434253655367}
COLUMN CELL
info:age timestamp=1434253655367,value=25
1 row(s) in 0.0450seconds
g) 全表扫描
hbase(main):071:0>scan 'member'
ROW COLUMN+CELL
xiaoming column=address:city, timestamp=1434254055056,value=guangzhou
xiaoming column=address:country,timestamp=1434254034436, value=china
xiaoming column=address:province,timestamp=1434254044916, value=guangdong
xiaoming column=info:age,timestamp=1434253975698, value=24
xiaoming column=info:birthday,timestamp=1434253997664, value=1990-03-22
xiaoming column=info:company,timestamp=1434254011707, value=tecent
xiaoming column=info:favorite,timestamp=1434254024140, value=movie
xueba column=address:city,timestamp=1434253878145, value=shenzhen
xueba column=address:country, timestamp=1434253848370, value=china
xueba column=address:province,timestamp=1434253860038, value=guangdong
xueba column=info:age,timestamp=1434254477087, value=26
xueba column=info:birthday,timestamp=1434253816609, value=1989-06-19
xueba column=info:company,timestamp=1434253830724, value=tecent
2 row(s) in 0.2120seconds
上面其实只有两行。
h) 删除数据
命令:delete
hbase(main):072:0>delete'member','xueba','info:age'
0 row(s) in0.0700 seconds
?
hbase(main):073:0> get'member','xueba'
COLUMN CELL
address:city timestamp=1434253878145,value=shenzhen
address:country timestamp=1434253848370,value=china
address:province timestamp=1434253860038,value=guangdong
info:birthday timestamp=1434253816609,value=1989-06-19
info:company timestamp=1434253830724, value=tecent
5 row(s) in0.0520 seconds
?
删除整行:deleteall
hbase(main):074:0>deleteall'member','xiaoming'
0 row(s) in0.0120 seconds
?
hbase(main):075:0>get'member','xiaoming'
COLUMN CELL
0 row(s) in 0.0130 seconds
?
查询表中还有多少行:count(每个行键对应一行)
hbase(main):076:0> count 'member'
1 row(s) in 0.0520 seconds
?
=> 1
?
?
截断表:truncate
hbase(main):077:0> truncate 'member'
Truncating 'member' table (it may take a while):
- Disabling table...
- Truncating table...
0 row(s) in 1.8140 seconds
可以看到truncate先disable然后truncate(先删除表(hdfs都删除了)再创建表)操作