SHELL
进入SHELL
hbase shell
查看所有表
list
创建表 test1,列族f11,f2,f3,f4
create 'test1','f1','f2','f3','f4'
对表table1添加一个新的列族
alter 'test1','f5'
删除表test1的一个列族 f5
alter 'test1',{NAME => 'f5',METHOD => 'delete'}
查看表test1的表信息
describe 'test1'
此命令显示出表test1的所有列族
hbase(main):002:0> describe 'test1'
Table test1 is ENABLED
test1
COLUMN FAMILIES DESCRIPTION
{NAME => 'f1', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLI
CATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}
{NAME => 'f2', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLI
CATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}
{NAME => 'f3', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLI
CATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}
{NAME => 'f4', VERSIONS => '1', EVICT_BLOCKS_ON_CLOSE => 'false', NEW_VERSION_BEHAVIOR => 'false', KEEP_DELETED_CELLS => 'FALSE', CACHE_DATA_ON_WRITE => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', REPLI
CATION_SCOPE => '0', BLOOMFILTER => 'ROW', CACHE_INDEX_ON_WRITE => 'false', IN_MEMORY => 'false', CACHE_BLOOMS_ON_WRITE => 'false', PREFETCH_BLOCKS_ON_OPEN => 'false', COMPRESSION => 'NONE', BLOCKCACHE => 'true', BLOCKSIZE => '65536'}
4 row(s)
Took 0.0863 seconds
向表test1中新增一行,rowid是 row1,列族在 f1 上(限定符是空),值是 this is the value of c1
向表test1中新增一行,rowid是 row1,列族在 f2(限定符是空) 上,值是 this is the value of f2
put 'test1','row1','f1','this is the value of c1'
put 'test1','row1','f2','this is the value of f2'
向表test1中新增一行,rowid是 row1,列族在 f3(限定符f3_qua) 上,值是 this is the value of f3_qua
put 'test1','row1','f3:f3_qua','this is the value of f3_qua'
查看rowid是row1这一行的数据
hbase(main):011:0> get 'test1','row1'
COLUMN CELL
f1: timestamp=1558360872899, value=this is the value of c1
f2: timestamp=1558361159073, value=this is the value of f2
f3:f3_qua timestamp=1558362080447, value=this is the value of f3_qua
1 row(s)
Took 0.0484 seconds
查看表test1中rowid是row1的f3列族中的具体的f3:f3_qua这一列的的数据
hbase(main):039:0> get 'test1','row1','f3:f3_qua'
COLUMN CELL
f3:f3_qua timestamp=1558363008280, value=this is the value of f3_qua
1 row(s)
Took 0.0332 seconds
删除rowid是row1这一行的列族是f3限定符是f3_qua的这一列数据
delete 'test1','row1','f3:f3_qua'
查看删除后的row1的数据
hbase(main):001:0> get 'test1','row1'
COLUMN CELL
f1: timestamp=1558360872899, value=this is the value of c1
f2: timestamp=1558361159073, value=this is the value of f2
1 row(s)
Took 1.1054 seconds
向表test1中新增一行,rowid是 row2,列族在 f1(限定符f1_qua) 上,值是 this is the value of f1_qua
put 'test1','row2','f1:f1_qua','this is the value of f1_qua'
查看表test1中的row2这一行的信息
hbase(main):014:0> get 'test1','row2'
COLUMN CELL
f1:f1_qua timestamp=1558362488274, value=this is the value of f1_qua
1 row(s)
Took 0.0119 seconds
查看表test1的所有rowKey
#查看row的行数
hbase(main):025:0> count 'test1'
2 row(s)
Took 0.0687 seconds
=> 2
#查看所有row的总行数和具体的的rowKey
hbase(main):030:0> count 'test1', INTERVAL=>1
Current count: 1, row: row1
Current count: 2, row: row2
2 row(s)
Took 0.0309 seconds
=> 2
删除表test1中的row2这一行的数据
deleteall 'test1','row2'
扫描整个表test1的数据
hbase(main):044:0> scan 'test1'
ROW COLUMN+CELL
row1 column=f1:, timestamp=1558360872899, value=this is the value of c1
row1 column=f2:, timestamp=1558361159073, value=this is the value of f2
row1 column=f3:, timestamp=1558361198732, value=this is the value of f3
row1 column=f3:f3_qua, timestamp=1558363008280, value=this is the value of f3_qua
row2 column=f1:f1_qua, timestamp=1558362733375, value=this is the value of f1_qua
2 row(s)
Took 0.1083 seconds
扫描整个表test1的f2列族的全部数据
hbase(main):056:0> scan 'test1',{COLUMN => 'f2'}
ROW COLUMN+CELL
row1 column=f2:, timestamp=1558361159073, value=this is the value of f2
1 row(s)
Took 0.0259 seconds
扫描整个表test1的f3列族的全部数据
hbase(main):062:0> scan 'test1',{COLUMN => 'f3'}
ROW COLUMN+CELL
row1 column=f3:, timestamp=1558361198732, value=this is the value of f3
row1 column=f3:f3_qua, timestamp=1558363008280, value=this is the value of f3_qua
1 row(s)
Took 0.0140 seconds
扫描整个表test1的f3列族中的f3:f3_qua限定符列的全部数据
hbase(main):069:0> scan 'test1',{COLUMN => 'f3:f3_qua'}
ROW COLUMN+CELL
row1 column=f3:f3_qua, timestamp=1558363008280, value=this is the value of f3_qua
1 row(s)
Took 0.0201 seconds
禁用、删除表test1
hbase(main):075:0> disable 'test1'
Took 1.9101 seconds
hbase(main):076:0> drop 'test1'
Took 2.6081 seconds
至此,基本操作已经能够满足日常SHELL的使用