基础操作
- 进入 HBase 客户端命令
bin/hbase shell
- 查看帮助命令
help - 查看数据库中表清单命令
hbase(main):051:0> list
TABLE
student
test1
表操作
- 创建表
hbase(main):003:0> create 'student' ,'info'
0 row(s) in 2.3680 seconds
- 插入数据
hbase(main):007:0> put 'student','1001','info:sex','male'
0 row(s) in 0.3080 seconds
- 查看表数据
hbase(main):009:0> scan 'student'
ROW COLUMN+CELL
1001 column=info:sex, timestamp=1592130567655, value=male
1 row(s) in 0.0910 seconds
- 查看表结构
hbase(main):010:0> describe 'student'
Table student is ENABLED
student
COLUMN FAMILIES DESCRIPTION
{NAME => 'info', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODIN
G => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICAT
ION_SCOPE => '0'}
1 row(s) in 0.0540 seconds
- 更新数据制定字段
put 'student','1001','info:name','Nick'
- 查看指定行执行列的数据
get 'student','1001'
get 'student','1001','info:name'
- 统计行数
hbase(main):014:0> count 'student'
1 row(s) in 0.0440 seconds
=> 1
- 删除某一行某一列数据
hbase(main):016:0> delete 'student','1002','info:sex'
0 row(s) in 0.0500 seconds
- 清空表数据
truncate 'student'
清空表前需要先 disable
10. 禁用/启用表
disable 'student'
- 删除表
hbase(main):082:0> disable 'student'
0 row(s) in 2.2880 seconds
hbase(main):083:0> drop 'student'
0 row(s) in 1.3240 seconds
hbase(main):084:0> list
TABLE
test1
1 row(s) in 0.0160 seconds
=> ["test1"]
- 变更表信息
alter 'student',{NAME=>'info',VERSIONS=>3}