当前位置: 移动技术网 > IT编程>数据库>MongoDB > 关于HBase Shell基本操作的表操作示例

关于HBase Shell基本操作的表操作示例

2018年11月24日  | 移动技术网IT编程  | 我要评论

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列族:nameagesexdept

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’

如对本文有疑问, 点击进行留言回复!!

相关文章:

验证码:
移动技术网