- 创建表
#语句末尾没有分号。这行语句创建表resume,表有三个列族:binfo、edu和work
hbase(main):001:0> create 'resume','binfo','edu','work'
0 row(s) in 2.8010 seconds
=> Hbase::Table - resume
- 列出表
hbase(main):002:0> list
TABLE
resume
1 row(s) in 0.0390 seconds
=> ["resume"]
- 查看表结构
hbase(main):003:0> describe 'resume'
Table resume is ENABLED
resume
COLUMN FAMILIES DESCRIPTION
{NAME => 'binfo', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_
VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
{NAME => 'edu', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VE
RSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
{NAME => 'work', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_V
ERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
3 row(s) in 0.1500 seconds
- 添加列族
hbase(main):007:0> disable 'resume'
0 row(s) in 2.3390 seconds
hbase(main):008:0> alter 'resume',name='f1'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.4730 seconds
hbase(main):009:0> describe 'resume'
Table resume is DISABLED
resume
COLUMN FAMILIES DESCRIPTION
{NAME => 'binfo', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_
VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
{NAME => 'edu', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VE
RSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
{NAME => 'f1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', COMPRESSION => 'NONE', VERSIONS => '1', TTL =>
'FOREVER', MIN_VERSIONS => '0', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
{NAME => 'work', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_V
ERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}
4 row(s) in 0.0360 seconds
- 删除列族
hbase(main):010:0> alter 'resume',{NAME=>'f1',METHOD=>'delete'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.2120 seconds
或者
hbase(main):021:0> alter 'resume','delete' => 'f1'
0 row(s) in 1.9310 seconds
hbase(main):022:0> enable 'resume'
0 row(s) in 5.9060 seconds
- 插入数据
hbase(main):013:0> put 'resume','lichangzai','binfo:age','1980-1-1'
0 row(s) in 0.1350 seconds
hbase(main):014:0> put 'resume','lichangzai','binfo:sex','man'
0 row(s) in 0.0240 seconds
hbase(main):015:0> put 'resume','lichangzai','edu:mschool','rq no.1'
0 row(s) in 0.0350 seconds
- 获取一行键的所有数据
hbase(main):016:0> get 'resume','lichangzai'
COLUMN CELL
binfo:age timestamp=1493947188657, value=1980-1-1
binfo:sex timestamp=1493947200815, value=man
edu:mschool timestamp=1493947210778, value=rq no.1
3 row(s) in 0.0840 seconds
- 获取一个行键,一个列族的所有数据
hbase(main):017:0> get 'resume','lichangzai','binfo'
COLUMN CELL
binfo:age timestamp=1493947188657, value=1980-1-1
binfo:sex timestamp=1493947200815, value=man
2 row(s) in 0.0210 seconds
- 获取一个行键,一个列族中一个列的所有数据
hbase(main):018:0> get 'resume','lichangzai','binfo:sex'
COLUMN CELL
binfo:sex timestamp=1493947200815, value=man
1 row(s) in 0.0210 seconds
- 更新一条记录
hbase(main):019:0> put 'resume','lichangzai','binfo:sex','13899999999'
0 row(s) in 0.0170 seconds
hbase(main):020:0> get 'resume','lichangzai','binfo:sex'
COLUMN CELL
binfo:sex timestamp=1493950679303, value=13899999999
1 row(s) in 0.0080 seconds
- 全表扫描
hbase(main):021:0> scan 'resume'
ROW COLUMN+CELL
lichangzai column=binfo:age, timestamp=1493947188657, value=1980-1-1
lichangzai column=binfo:sex, timestamp=1493950679303, value=13899999999
lichangzai column=edu:mschool, timestamp=1493947210778, value=rq no.1
1 row(s) in 0.0480 seconds
-
网友评论