如果想查看所有关于hbase shell的命令在命令行工具中输入help
如果想查看某个命令的话输入help ”命令名称“
我们就查看一个get命令举例:
get 命令相当于指定行select 语句
我们执行help get
hbase(main):003:0> help “get”
Get row or cell contents; pass table name, row, and optionally
获取行或者是单元内容;通过表明 ,行,以及可选项
a dictionary of column(s), timestamp, timerange and versions. Examples:
列的字典、时间戳、时间范围、版本号
hbase> get ‘ns1:t1’, ‘r1’
获取指定命名空间ns1,表示t1,行号是r1的整个行
hbase> get ‘t1’, ‘r1’
获取默认命名空间的表t1,行号是r1的行
hbase> get ‘t1’, ‘r1’, {TIMERANGE => [ts1, ts2]}
获取默认命名空间的表是t1,行号是r1,时间范围在ts1和ts2之间的行
hbase> get ‘t1’, ‘r1’, {COLUMN => ‘c1’}
获取默认空间下表是t1,行号是r1,只返回列c1
hbase(main):012:0> get "mystudent","s001",{COLUMN => 'info:name'}
COLUMN CELL
info:name timestamp=1586705260807, value=Tom
1 row(s)
Took 0.1403 seconds
获取默认命名空间的表是t1,行号是r1,
以下类似就不一一列举了
hbase> get ‘t1’, ‘r1’, {COLUMN => [‘c1’, ‘c2’, ‘c3’]}
hbase> get ‘t1’, ‘r1’, {COLUMN => ‘c1’, TIMESTAMP => ts1}
hbase> get ‘t1’, ‘r1’, {COLUMN => ‘c1’, TIMERANGE => [ts1, ts2], VERSIONS => 4}
hbase> get ‘t1’, ‘r1’, {COLUMN => ‘c1’, TIMESTAMP => ts1, VERSIONS => 4}
hbase> get ‘t1’, ‘r1’, {FILTER => “ValueFilter(=, ‘binary:abc’)”}
hbase> get ‘t1’, ‘r1’, ‘c1’
hbase> get ‘t1’, ‘r1’, ‘c1’, ‘c2’
hbase> get ‘t1’, ‘r1’, [‘c1’, ‘c2’]
hbase> get ‘t1’, ‘r1’, {COLUMN => ‘c1’, ATTRIBUTES => {‘mykey’=>‘myvalue’}}
hbase> get ‘t1’, ‘r1’, {COLUMN => ‘c1’, AUTHORIZATIONS => [‘PRIVATE’,‘SECRET’]}
hbase> get ‘t1’, ‘r1’, {CONSISTENCY => ‘TIMELINE’}
hbase> get ‘t1’, ‘r1’, {CONSISTENCY => ‘TIMELINE’, REGION_REPLICA_ID => 1}
Besides the default ‘toStringBinary’ format, ‘get’ also supports custom formatting by
column. A user can define a FORMATTER by adding it to the column name in the get
specification. The FORMATTER can be stipulated:
Example formatting cf:qualifier1 and cf:qualifier2 both as Integers:
hbase> get ‘t1’, ‘r1’ {COLUMN => [‘cf:qualifier1:toInt’,
‘cf:qualifier2:c(org.apache.hadoop.hbase.util.Bytes).toInt’] }
Note that you can specify a FORMATTER by column only (cf:qualifier). You can set a
formatter for all columns (including, all key parts) using the “FORMATTER”
and “FORMATTER_CLASS” options. The default “FORMATTER_CLASS” is
“org.apache.hadoop.hbase.util.Bytes”.
hbase> get ‘t1’, ‘r1’, {FORMATTER => ‘toString’}
hbase> get ‘t1’, ‘r1’, {FORMATTER_CLASS => ‘org.apache.hadoop.hbase.util.Bytes’, FORMATTER => ‘toString’}