HBase学习笔记——基本CRUD操作

进入HBase的安装目录,启动HBase

bin/start-hbase.sh

打开shell命令行模式

bin/hbase shell

关闭HBase

bin/stop-hbase.sh

 

一个cell的值,取决于Row,Column family,Column Qualifier和Timestamp

HBase表结构

 

1.查看当前用户

hbase(main):001:0> whoami
hbase/master@HADOOP.COM (auth:KERBEROS)

2. HBase中创建表,这里面的name,sex,age,dept,course都是column-family

create 'student','name','sex','age','dept','course'

3.列出表

hbase(main):005:0> list
TABLE
0 row(s) in 0.0170 seconds

=> []

4.HBase中添加数据,当添加了数据之后,就有了column,‘1000’是ROW

put 'student','1000','name','XiaoMing'  #这么写的话,family为name,column为空
put 'student','1000','course:math','99'  #这么写的话,family为course,column为math

5.HBase中查看表

desc 'student'
#或者
scan 'student'

 

6.HBase中查看某一列

scan 'student',{COLUMN=>'name'}

 

7.HBase中查看一行

get 'student',1000

 

8.查看特定行的某几列

get 'student',1000,'name','sex'

9.HBase中删除某一行的某一列数据

delete 'student','1000','name'

10.HBase中删除某一行的数据

deleteall 'student','1000'

11.删除某个表

disable ‘student’
drop 'student'    #删除之前必须先disable

12.统计记录数

count 'student'

13.清空表

truncate 'student'

14.limit查看1条

scan 'student',{LIMIT=>1}

15.给用户赋权

给hive用户赋予all权限

hbase(main):001:0> grant 'hive','A'
0 row(s) in 0.2550 seconds

参考:HBase的ACL说明

 

posted @ 2017-04-12 22:09  tonglin0325  阅读(1418)  评论(0编辑  收藏  举报