Hbase_shell操作

创建表

create 'user_action_table', 'action_log', 'action'
-- 执行结果
=> Hbase::Table - m_table

描述表信息

desc 'm_table'
-- 执行结果
DESCRIPTION                               ENABLED                            
'm_table', {NAME => 'action', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => true 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}, {NAME => 'meta_data', BLOOMFILTER => 'ROW', VERSIONS => '1', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'false', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER',COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACHE => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}        

增加列蔟

alter 'm_table', {NAME=>'cf_new', VERSIONS=>3, IN_MEMORY=>true}
-- 执行结果
Updating all regions with the new schema...
0/1 regions updated.
1/1 regions updated.
Done.

删除列蔟

alter 'm_table', {NAME=>'action', METHOD=>'delete'}
-- 执行结果
Updating all regions with the new schema...
0/1 regions updated.
1/1 regions updated.
Done.

删除表

disable 'm_table'
drop 'm_table'

写数据

put 'm_table', '1001', 'meta_data:name', 'zhang3'
put 'm_table', '1002', 'meta_data:name', 'li4'
put 'm_table', '1001', 'meta_data:age', '18'
put 'm_table', '1002', 'meta_data:gender', 'man'

读数据

-- 批量读
scan 'm_table'
-- 执行结果
ROW                                         COLUMN+CELL                                                                                                                      
1001                                       column=meta_data:age, timestamp=1537187946181, value=18                                                                          
1001                                       column=meta_data:name, timestamp=1537187946134, value=zhang3                                                                      
1002                                       column=meta_data:gender, timestamp=1537187947640, value=man                                                                      
1002                                       column=meta_data:name, timestamp=1537187946164, value=li4

-- 逐条读
get 'm_table', '1001'
get 'm_table', '1001', 'meta_data:name'
get 'm_table', '1002', {COLUMN=>'meta_data:gender', TIMESTAMP=>1536415926706}

查看行数

count 'm_table'

清空词表

truncate 'm_table'

猜你喜欢

转载自www.cnblogs.com/zxbdboke/p/10465885.html