赞
踩
本篇博文主要举一个例子来说明一下HBase shell,文末将会介绍两篇详细的关于HBase常用Shell使用的博文。
name | score | ||
English | Math | Computer | |
zhangsan | 69 | 86 | 77 |
lisi | 55 | 100 | 88 |
根据上面给出的Student表的信息,执行如下操作。
1.用HBase Shell命令创建学生表Student,并将数据插入表中。
- 进入hbase shell
-
- [hadoop@MASTER ~]$ hbase shell
- 创建student表和score列族
- hbase(main):011:0> create 'student','score'
- 0 row(s) in 1.2810 seconds
- => Hbase::Table - student
- 添加数据到表中
- hbase(main):012:0> put 'student','zhangsan','score:English','69'
- 0 row(s) in 0.1320 seconds
-
- hbase(main):013:0> put 'student','zhangsan','score:Math','86'
- 0 row(s) in 0.0090 seconds
-
- hbase(main):014:0> put 'student','zhangsan','score:Computer','77'
- 0 row(s) in 0.0110 seconds
- hbase(main):001:0> put 'student','lisi','score:English','55'
- 0 row(s) in 0.8190 seconds
-
- hbase(main):002:0> put 'student','lisi','score:Math','100'
- 0 row(s) in 0.0200 seconds
-
- hbase(main):003:0> put 'student','lisi','score:Computer','88'
- 0 row(s) in 0.0250 seconds

2. 用Scan命令浏览Student表的相关信息。
hbase(main):004:0> scan 'student'
3. 查询zhangsan的Computer成绩。
hbase(main):005:0> get 'student','zhangsan','score:Computer'
4. 修改lisi的Math成绩,改为95。
修改成绩,也就是把成绩覆盖
hbase(main):009:0> put 'student','lisi','score:Math','95'
5. 向Student表中添加数据:name为wangwu,English为80,Math为90,Computer为100,History为70。
6. 统计表的行数。
count 'student'
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。