[grid@hdnode3 ~]$ hbase shell
HBase Shell; enter ¨help¨ for list of supported commands.
Type "exit" to leave the HBase Shell
Version 0.90.5, r1212209, Fri Dec 9 05:40:36 UTC 2011
hbase(main):001:0>
输出的格式也是JSON串的形式,从中可以看到保留的版本数,TTL号(Time to Live,保留时间),列的定义,块大小等等。
修改表对象,修改(含删除)前必须首先禁用对象,执行修改命令成功后,再启用对象。
禁用对象:
hbase(main):004:0> disable ¨t¨
0 row(s) in 2.0430 seconds
判断当前表对象启用或禁用:
hbase(main):007:0> is_enabled ¨t¨
false
0 row(s) in 0.0040 seconds
hbase(main):008:0> is_disabled ¨t¨
true
0 row(s) in 0.0040 seconds
修改表对象,增加一个列族:
hbase(main):021:0> alter ¨t¨, {NAME => ¨t_info¨, VERSIONS => 3}
0 row(s) in 0.0360 seconds
hbase(main):023:0> enable ¨t¨
0 row(s) in 2.0250 seconds
插入记录:
hbase(main):025:0> put ¨t¨,¨10001¨,¨t_vl:name¨,¨jss¨
0 row(s) in 0.0060 seconds
hbase(main):026:0> put ¨t¨,¨10001¨,¨t_vl:age¨,¨99¨
0 row(s) in 0.0070 seconds
hbase(main):027:0> put ¨t¨,¨10001¨,¨t_info:general¨,¨his fullname is junsanis!¨
0 row(s) in 0.0040 seconds
记录获取:
hbase(main):028:0> get ¨t¨,¨10001¨
COLUMN CELL
t_info:general timestamp=1365670813664, value=his fullname is junsanis!
t_vl:age timestamp=1365670733223, value=99
t_vl:name timestamp=1365670723056, value=jss
3 row(s) in 0.0450 seconds
获取指定记录中指定列族的数据:
hbase(main):029:0> get ¨t¨,¨10001¨,¨t_vl¨
COLUMN CELL
t_vl:age timestamp=1365670733223, value=99
t_vl:name timestamp=1365670723056, value=jss
2 row(s) in 0.0070 seconds
获取指定记录中指定列族中指定列的数据:
hbase(main):030:0> get ¨t¨,¨10001¨,¨t_vl:age¨
COLUMN CELL
t_vl:age timestamp=1365670733223, value=99
1 row(s) in 0.0070 seconds
记录更新(跟插入没有区别):
hbase(main):031:0> put ¨t¨,¨10001¨,¨t_vl:age¨,¨10¨
0 row(s) in 0.0050 seconds
hbase(main):032:0> get ¨t¨,¨10001¨,¨t_vl:age¨
COLUMN CELL
t_vl:age timestamp=1365670912700, value=10
1 row(s) in 0.0080 seconds