HBase Shell

HBase Shell,第1张

HBase Shell 1、启动hbase

start-hbase.sh

2、进入hbase shell命令行

hbase shell 

注意:直接按删除,只会从光标所在处往后删

           要想正常删除,按住ctrl

3、基本命令

创建表

1) create 'test','info' 

2) create 'test',{NAME=>'info',VERSION=>3}

3) create 'test',{NAME=>'cf1',TTL=>5}

删除表

1)disable 'test'

2) drop 'test' 

列出所有表(用户表) 

 list

添加数据

1) put 'test','001','info:name','张三‘

2) put 'test','001','info:age','25' 

获取数据

获取一定范围的数据

1) scan 'test'

2) scan 'test',{LIMIT=>3}

3) scan 'test',{STARTROW=>'001',ENDROW=>'004'} 

获取一条数据

1) get 'test','001'

2) get 'test','001',{COLUMN=>'info',VERSION=>3}

添加新列簇

alter 'student',{NAME=>cf1} 

 删除原列簇

alter 'student','delete'=>'cf2'

根据列名删除cell

delete 'testAPI','0001','cf1:age' 

根据rowkey删除cell

deleteall 'testAPI','0002' 

清空表中数据(会影响region数量,回到初始化状态1)

truncate 'test' 

查询数据条数

count 'test' 

 


4、不常用命令

查看系统表

> list_namespace_tables 'hbase'

TABLE                                                                                             
meta                                                                                              
namespace 

查看命名空间

> list_namespace 

NAMESPACE                                                                                         
default                                                                                           
hbase 

注意:创建的用户表默认在default下

创建命名空间

create_namespace 'ns1'

在指定命名空间建表 

create 'ns1:ns_table','info'

 

欢迎分享,转载请注明来源:内存溢出

原文地址: https://outofmemory.cn/zaji/5636007.html

(0)
打赏 微信扫一扫 微信扫一扫 支付宝扫一扫 支付宝扫一扫
上一篇 2022-12-16
下一篇 2022-12-16

发表评论

登录后才能评论

评论列表(0条)

保存