HBase基本操作04

最后,我们说一些不那么常用的操作吧:

新增列族:

hbase(main):036:0> alter 'patientvisit', NAME=>'cftest'
Updating all regions with the new schema...
0/1 regions updated.
1/1 regions updated.
Done.
0 row(s) in 3.5200 seconds

修改列族:

hbase(main):039:0> alter 'patientvisit', NAME=>'cftest', VERSIONS=>3
Updating all regions with the new schema...
0/1 regions updated.
1/1 regions updated.
Done.
0 row(s) in 3.0070 seconds

删除列族:

hbase(main):040:0> alter 'patientvisit', NAME=>'cftest', METHOD=>'delete'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.4890 seconds

列出namespace:

hbase(main):042:0> list_namespace
NAMESPACE                                                                                                                                                    
default                                                                                                                                                      
hbase                                                                                                                                                        
2 row(s) in 0.0550 seconds


创建namespace:

hbase(main):043:0> create_namespace 'mynamespace'
0 row(s) in 0.1240 seconds

查看namespace情况:

hbase(main):044:0> describe_namespace 'mynamespace'
DESCRIPTION                                                                                                                                                  
{NAME => 'mynamespace'}                                                                                                                                      
1 row(s) in 0.0250 seconds

带namespace的日常操作:

hbase(main):045:0> create 'mynamespace:testtable','fm01','fm02','fm03'
0 row(s) in 2.4190 seconds

=> Hbase::Table - mynamespace:testtable
hbase(main):046:0> list_namespace_tables 'mynamespace'
TABLE                                                                                                                                                        
testtable                                                                                                                                                    
1 row(s) in 0.0850 seconds

hbase(main):047:0> describe 'mynamespace:testtable'
Table mynamespace:testtable is ENABLED                                                                                                                       
mynamespace:testtable                                                                                                                                        
COLUMN FAMILIES DESCRIPTION                                                                                                                                  
{NAME => 'fm01', 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 => 'fm02', 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 => 'fm03', 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'}                                           
3 row(s) in 0.0280 seconds

hbase(main):048:0> put 'mynamespace:testtable','row001','fm01:col01','testcelldata'
0 row(s) in 0.0230 seconds

hbase(main):049:0> get 'mynamespace:testtable','row001'
COLUMN                                   CELL                                                                                                                
 fm01:col01                              timestamp=1454470610274, value=testcelldata                                                                         
1 row(s) in 0.0100 seconds

删除namespace(只能删除空的namespace哦):

hbase(main):050:0> drop_namespace 'mynamespace'
Drop the named namespace. The namespace must be empty.

Comments are closed.