您的位置:首页 > 运维架构 > Shell

Hbase 基本shell操作命令

2014-12-22 14:32 375 查看
1.创建表(hbase 建立表示要求必须确定列簇)

下面建立了一个表名字为scores的表。其中有两个列簇,一个是grade,一个是course;

create 'scores','grade','course'

2.查看hbase中所有表

list

3 查看表结构

describe ‘scores’

4 插入数据

向scores表中插入一行,行健是tom,grade的值是5

put 'scores','tom','grade:','5'

向scores表中插入一行,行健是tom,列math,的值是80

put 'scores','tom','course:math','80'

向scores表中插入一行,行健是jim,grade的值是4

put 'scores','jim','grade','5'

向scores表中插入一行,行健是jim,列english,的值是90

put 'scores','tom','course:english,'80'
(hbase中的列是可以动态改变的)

5 删除指定数据

delete ‘scores’,'jim','grade'

deleteall 整个行的删除

truncate ‘scores’ 全表删除,结构还在

6 修改表结构

disable 'scores'

alter 'scores',NAME=>'info' 添加一个列簇

enable 'scores'

7 删除一个列簇

alter 'scores',NAME=>'info',METHOD=>'delete'

alter 'scores','delete'=>'info'

8 修改一个列簇

将info列簇的版本数量改为3个

alter ‘scores’,{NAME=>'info',VERSIONS=>3}

9 统计行数

count ‘scores’ 使用mapreduce进行统计

count ‘scores’ ,INTERVAL=>10,CACHE=>1000

默认统计1000行(INTERVAL)结果会进行缓存
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签: