HBase(2)-操作命令DDL

创建表  create

指令格式:create 表名,列簇1,....,列簇n

hbase(main):010:0> create 'tbTest','col-familyA','col-familyB'
0 row(s) in 2.4910 seconds



create 't1', 'f1', SPLITS => ['10', '20', '30', '40']

create 't1', {NAME =>'f1', TTL => 180}, SPLITS => ['10', '20', '30', '40']

create 't1', {NAME =>'f1', TTL => 180}, {NAME => 'f2', TTL => 240}, SPLITS => ['10', '20', '30', '40']

查询表 list

hbase(main):011:0> list
TABLE

t1

tbTest

2 row(s) in 0.0040 seconds

=> ["t1", "tbTest"]

表描述 describe

指令格式: describe 表名

hbase(main):015:0> describe 't1'
Table t1 is ENABLED

t1

COLUMN FAMILIES DESCRIPTION

{NAME => 'f1', BLOOMFILTER => 'ROW', VERSIONS => '2', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACH
E => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}

{NAME => 'f2', BLOOMFILTER => 'ROW', VERSIONS => '2', IN_MEMORY => 'false', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', TTL => 'FOREVER', COMPRESSION => 'NONE', MIN_VERSIONS => '0', BLOCKCACH
E => 'true', BLOCKSIZE => '65536', REPLICATION_SCOPE => '0'}

2 row(s) in 0.0780 seconds

禁用表 disable

指令格式: disable 表名

hbase(main):016:0> disable 't1'
0 row(s) in 4.4590 seconds

删除表  drop    (删除表要先禁用(disable)表)

指令格式: drop 表名  

hbase(main):017:0> describe 't1'
Table t1 is DISABLED

2 row(s) in 0.0480 seconds

hbase(main):018:0> drop 't1'
0 row(s) in 2.3840 seconds

启用表 enable

指令格式: enable 表名

hbase(main):020:0> disable 'tbTest'
0 row(s) in 2.3030 seconds

hbase(main):022:0> enable 'tbTest'
0 row(s) in 2.3820 seconds

验证已经启用表

指令格式: is_enabled 表名

hbase(main):023:0> is_enabled 'tbTest'
true

验证已经禁用表

指令格式: is_disabled 表名

hbase(main):024:0> is_disabled 'tbTest'
false

验证表存在 exists

指令格式: exists 表名

hbase(main):029:0> exists 'tbTest'
Table tbTest does exist

修改表 alter (修改前要先禁用表)

指令格式: alter 表名,指令1,......,指令m

模版

There could be more than one alteration in one command:

  hbase> alter 't1', { NAME => 'f1', VERSIONS => 3 },
   { MAX_FILESIZE => '134217728' }, { METHOD => 'delete', NAME => 'f2' },
   OWNER => 'johndoe', METADATA => { 'mykey' => 'myvalue' }

增加列  

hbase(main):040:0> alter 'tbTest',NAME => 'col-familyC'
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 2.5760 seconds

删除列

hbase(main):003:0> alter 'tbTest',{NAME=>'col-familyC',METHOD=>'delete'}
Updating all regions with the new schema...
1/1 regions updated.
Done.
0 row(s) in 3.0540 seconds

清空表数据  truncate (清空前表要启用)

指令格式: truncate 表名

hbase(main):007:0> enable 'tbTest'
0 row(s) in 2.3410 seconds

hbase(main):008:0> truncate 'tbTest'
Truncating 'tbTest' table (it may take a while):
 - Disabling table...
 - Truncating table...
0 row(s) in 5.0260 seconds

删除匹配表 drop_all (删除表前要禁用表)

指令格式: drop_all 正则表达式

hbase(main):012:0> list
TABLE

t1

t2

tbTest

3 row(s) in 0.0310 seconds

=> ["t1", "t2", "tbTest"]
hbase(main):013:0> drop_all 't[0-9]'
t1

t2


Drop the above 2 tables (y/n)?
y

 

  • 0
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值