关于HBase Shell命令基本操作示例

HBase 为用户提供了一个非常方便的使用方式, 我们称之为“HBase Shell”。

HBase Shell 提供了大多数的 HBase 命令, 通过 HBase Shell 用户可以方便地创建、删除及修改表, 还可以向表中添加数据、列出表中的相关信息等。

用HBase shell进行表操作

1. 创建student表,表结构包含info和course列族,显示表结构。

create ‘student’,‘info’,‘course’

desc ‘student’

2. 修改表结构,course列族返回最大版本数为3,显示表结构。

alter ‘student’,{NAME=>‘course’,VERSIONS=>3}

describe ‘student’

3. 输入数据,要求至少包括以下列

(具体数据自定,course列族要输入部分小于60分的数据)

info列族:name、age、sex、dept

course列族:english、math、physics

put ‘student’,‘001’,‘info:name’,‘liu’,3

put ‘student’,‘001’,‘info:age’,‘18’,11

put ‘student’,‘001’,‘info:sex’,‘nan’,15

put ‘student’,‘001’,‘info:dept’,‘JAVA’,10

put ‘student’,‘002’,‘info:name’,‘ma’,8

put ‘student’,‘002’,‘info:age’,‘19’,2

put ‘student’,‘002’,‘info:sex’,‘nan’,5

put ‘student’,‘002’,‘info:dept’,‘WEB’,10

put ‘student’,‘003’,‘info:name’,‘zhang’,6

put ‘student’,‘003’,‘info:age’,‘18’,4

put ‘student’,‘003’,‘info:sex’,‘nv’,10

put ‘student’,‘003’,‘info:dept’,‘JS’,9

put ‘student’,‘001’,‘course:english’,‘69’,13

put ‘student’,‘001’,‘course:math’,‘92’,16

put ‘student’,‘001’,‘course:physics’,‘46’,20

put ‘student’,‘002’,‘course:english’,‘89’,13

put ‘student’,‘002’,‘course:math’,‘64’,16

put ‘student’,‘002’,‘course:physics’,‘59’,17

put ‘student’,‘003’,‘course:english’,‘70’,13

put ‘student’,‘003’,‘course:math’,‘35’,16

put ‘student’,‘003’,‘course:physics’,‘72’,21

4. 更新数据,将course列族中小于60的数据更新为60。

put  ‘student’,‘001’,‘ course:physics’,‘60’,20

put  ‘student’,‘002’,‘ course:physics’,‘60’,17

5. 使用get进行数据查询。

get ‘student’,‘001’

6. 使用scan进行查询。

scan ‘student’

7. 使用列族过滤器进行查询。

scan‘student’,FILTER=>“FamilyFilter(=,‘substring:info’)”

8. 创建student表的快照stu_snap,显示快照列表。

snapshot ‘student’,‘stu_snap’

list_snapshots

9. 通过快照stu_snap生成新表stu_info,并显示stu_info表结构。

clone_sanpshot ‘stu_snap’,‘stu_info’

 desc ‘stu_info’

10. 删除快照stu_snap,删除student表。

disable ‘student’

drop ‘student’

delete_snapshot ‘stu_snap’

posted @ 2018-11-23 21:52  Kiiyan  阅读(597)  评论(0编辑  收藏  举报