Java教程

Hbase Shell的基本操作

本文主要是介绍Hbase Shell的基本操作,对大家解决编程问题具有一定的参考价值,需要的程序猿们随着小编来一起学习吧!

一、基本操作

1.进入HBase客户端命令

bin/hbase shell

2.查看帮助命令

help

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

list

二、表的操作

1.创建表

create 'student','info'

2.插入数据到表中

> put 'student','1001','info:sex','male'
> put 'student','1001','info:age','18'
> put 'student','1002','info:name','jerry'
> put 'student','1002','info:age','20'
> put 'student','1002','info:sex','female'

3.扫描查看表数据

> scan 'student'
> scan 'student',{STARTROW => '1001',STOPROW => '1001'}
> scan 'student',{STARTROW => '1001'}

4.查看表结构

> describe 'student'

5.更新指定字段的数据

> put 'student','1001','info:name','Nick'
> put 'student','1001','info:age','100'

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

> get 'student','1001'
> get 'student','1001','info:name'

7.统计表数据行数

> count 'student'

8.删除数据

# 删除某rowkey的全部数据
> deleteall 'student','1001'
# 删除某rowkey的某一列数据
> delete 'student','1002','info:sex'

9.清空表数据

> truncate 'student'

注意:清空表的操作为先disable,然后再truncate。

10.删除表

# 首先需要先让该表为disable状态
> disable 'student'
# 然后才能drop这个表
> drop 'student'

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

11.变更表信息

# 将info列族中的数据存放3个版本
> alter 'student',{NAME=>'info',VERSION=>3}
> get 'student','1001',{COLUMN=>'info:name',VERSION=>3}

 

这篇关于Hbase Shell的基本操作的文章就介绍到这儿,希望我们推荐的文章对大家有所帮助,也希望大家多多支持为之网!