Hbase教程
作者: 时海 风自在
Hbase 表命令

1、列出所有表

hbase(main):004:0> list
TABLE                                                                                                   
test1                                                                                         
table2                                                                                      
table3
3 row(s) in 0.0680 seconds                                                                  
2、创建表
hbase(main):001:0> create 'table1',{NAME => 'colfamily1', VERSIONS => 1},{NAME => 'colfamily2', VERSIONS => 1}

0 row(s) in 0.6650 seconds
=> Hbase::Table - table1
3、查看表的描述信息
hbase(main):004:0> describe 'table1'
Table table1 is ENABLED                                                                                   
table1                                                                                                    
COLUMN FAMILIES DESCRIPTION                                                                               
{NAME => 'colfamily1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERS
IONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', 
BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}                                         
{NAME => 'colfamily2', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERS
IONS => '1', COMPRESSION => 'NONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', 
BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}                                         
2 row(s) in 0.0210 seconds

4、禁用表

hbase(main):002:0> disable 'table1'
0 row(s) in 1.1830 seconds
5、启用表


hbase(main):003:0> enable 'table1'
0 row(s) in 0.3920 seconds

6、删除表

 删除表之前需要先禁用表(disable '<table>'), 否则会报如下错误:

hbase(main):005:0> drop 'table1' 

ERROR: Table table1 is enabled. Disable it first.

Here is some help for this command:
Drop the named table. Table must first be disabled:
  hbase> drop 't1'
  hbase> drop 'ns1:t1'


正确删除步骤:

hbase(main):006:0> disable 'table1'
0 row(s) in 1.1610 seconds

hbase(main):007:0> drop 'table1'
0 row(s) in 0.3510 seconds

标签: table1、hbase、row、seconds、drop
一个创业中的苦逼程序员
  • 回复
隐藏