[HBase] hbase shell 表定义

登录

[sparkadmin@Sit-Spark-02 ~]$ hbase shell
16/09/27 14:35:05 INFO Configuration.deprecation: hadoop.native.lib is deprecated. Instead, use io.native.lib.available
HBase Shell; enter 'help<RETURN>' for list of supported commands.
Type "exit<RETURN>" to leave the HBase Shell
Version 1.2.0-cdh5.8.0, rUnknown, Tue Jul 12 16:09:11 PDT 2016

表是否存在


hbase(main):001:0> exists 'tmp'
Table tmp does not exist                                                                                                          
0 row(s) in 0.5420 seconds

创建表

  • 建表语句
create 'tablename','col1','col2',...,'colN'
  • 建表
hbase(main):002:0> create 'tmp','col1','col2'
0 row(s) in 2.4920 seconds

=> Hbase::Table - tmp
  • 查看表
=> Hbase::Table - tmp
hbase(main):003:0> list 'tmp'
TABLE                                                                                                                             
tmp                                                                                                                               
1 row(s) in 0.0240 seconds

=> ["tmp"]
  • 查看表详细信息
hbase(main):004:0> desc 'tmp'
Table tmp is ENABLED                                                                                                              
tmp                                                                                                                               
COLUMN FAMILIES DESCRIPTION                                                                                                       
{NAME => 'col1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'N
ONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE
 => 'true'}                                                                                                                       
{NAME => 'col2', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'N
ONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE
 => 'true'}                                                                                                                       
2 row(s) in 0.0770 seconds

修改表

  • 查看表是否存在
hbase(main):005:0> exists 'tmp'
Table tmp does exist                                                                                                              
0 row(s) in 0.0340 seconds
  • disable表
hbase(main):006:0> disable 'tmp'
0 row(s) in 2.3600 seconds
  • 删除某列族

hbase(main):007:0> alter 'tmp', name=>'col2', method=>'delete'
NameError: undefined local variable or method `name' for #<Object:0xe014c4e>

hbase(main):008:0> alter 'tmp',NAME=>'col2',METHOD=>'delete'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.8110 seconds
  • 添加列族

hbase(main):046:0> alter 'tmp',NAME='col3',METHOD='add'
Updating all regions with the new schema...
0/1 regions updated.
1/1 regions updated.
Done.
Updating all regions with the new schema...
0/1 regions updated.
1/1 regions updated.
Done.
0 row(s) in 7.5210 seconds
  • enable表
hbase(main):010:0> is_enabled 'tmp'
false                                                                                                                             
0 row(s) in 0.0490 seconds

hbase(main):012:0> enable 'tmp'
0 row(s) in 2.3990 seconds

hbase(main):013:0> is_enabled 'tmp'
true                                                                                                                              
0 row(s) in 0.0400 seconds
  • 查看表结构
hbase(main):014:0> desc 'tmp'
Table tmp is ENABLED                                                                                                              
tmp                                                                                                                               
COLUMN FAMILIES DESCRIPTION                                                                                                       
{NAME => 'col1', DATA_BLOCK_ENCODING => 'NONE', BLOOMFILTER => 'ROW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'N
ONE', MIN_VERSIONS => '0', TTL => 'FOREVER', KEEP_DELETED_CELLS => 'FALSE', BLOCKSIZE => '65536', IN_MEMORY => 'false', BLOCKCACHE
 => 'true'}                                                                                                                       
1 row(s) in 0.0530 seconds

删除表

  • 检查是否disable
hbase(main):011:0> is_disabled 'tmp'
true                                                                                                                              
0 row(s) in 0.0440 seconds
  • disable 表
hbase(main):015:0> disable 'tmp'
0 row(s) in 4.3440 seconds
  • 删除表
hbase(main):016:0> drop 'tmp'
0 row(s) in 2.3410 seconds
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值