[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
本站文章为和通数据库网友分享或者投稿,欢迎任何形式的转载,但请务必注明出处.
同时文章内容如有侵犯了您的权益,请联系QQ:970679559,我们会在尽快处理。