博客 HBase Shell操作

HBase Shell操作

   数栈君   发表于 2024-07-31 15:25  217  0

基本操作


1.进入HBase客户端命令行

[root@cdh02 current]# hbase shell


2.查看帮助命令

hbase(main):001:0> help


3.查看当前数据库中有哪些表

hbase(main):002:0> list


表的操作

1.创建表

hbase(main):002:0> create 'student_test','info'

2.插入数据到表

hbase(main):003:0> put 'student','1001','info:sex','male'

hbase(main):004:0> put 'student','1001','info:age','18'

hbase(main):005:0> put 'student','1111','info:name','kun'

hbase(main):006:0> put 'student','1002','info:sex','female'

hbase(main):007:0> put 'student','1002','info:age','20'


3.扫描查看表数据

hbase(main):008:0> scan 'student_test'

hbase(main):009:0> scan 'student_test',{STARTROW => '1001', STOPROW  => '1001'}

hbase(main):010:0> scan 'student_test',{STARTROW => '1001'}


4.查看表结构

hbase(main):011:0> describe student


5.更新指定字段的数据

hbase(main):012:0> put 'student','1001','info:name','Nick'

hbase(main):013:0> put 'student','1001','info:age','100'


6.查看“指定行”或“指定列族:列”的数据

hbase(main):014:0> get 'student','1001'

hbase(main):015:0> get 'student','1001','info:name'


7.统计表数据行数

hbase(main):021:0> count 'student'


8.删除数据

删除某rowkey的全部数据:

hbase(main):016:0> deleteall 'student','1001'

删除某rowkey的某一列数据:

hbase(main):017:0> delete 'student','1002','info:sex'


9.清空表数据

提示:清空表的操作顺序为先disable,然后再truncate

hbase(main):018:0> truncate 'student'


10.删除表

提示:如果直接drop表,会报错:ERROR: Table student is enabled. Disable it first.

首先需要先让该表为disable状态:

hbase(main):019:0> disable 'student'

然后才能drop这个表:

hbase(main):020:0> drop 'student'


11.变更表信息

info列族中的数据存放3个版本:

hbase(main):022:0> alter 'student',{NAME=>'info',VERSIONS=>3}

hbase(main):022:0> get 'student','1001',{COLUMN=>'info:name',VERSIONS=>3}


《行业指标体系白皮书》下载地址:https://www.dtstack.com/resources/1057/?src=bbs

《数据治理行业实践白皮书》下载地址:https://www.dtstack.com/resources/1001/?src=bbs

《数栈V6.0产品白皮书》下载地址:https://www.dtstack.com/resources/1004/?src=bbs

想了解或咨询更多有关袋鼠云大数据产品、行业解决方案、客户案例的朋友,浏览袋鼠云官网:https://www.dtstack.com/?src=bbs

同时,欢迎对大数据开源项目有兴趣的同学加入「袋鼠云开源框架钉钉技术群」,交流最新开源技术信息,群号码:30537511,项目地址:https://github.com/DTStack

0条评论
上一篇:HBase数据结构
下一篇:
社区公告
  • 大数据领域最专业的产品&技术交流社区,专注于探讨与分享大数据领域有趣又火热的信息,专业又专注的数据人园地

最新活动更多
微信扫码获取数字化转型资料
钉钉扫码加入技术交流群