HBase shell
一、kerberos认证命令
kinit -kt */*.keytab hbase
二、表的管理
1、查看表的列表
list
2、创建表
语法:create 't1', {NAME => 'f1', VERSIONS => 1}, {NAME => 'f2', VERSIONS => 1}
create 'tablename',{NAME=>'f1',VERSIONS=>2},{NAME=>'f2',VERSIONS=>2}
3、删除表
disable 'tablename'
drop tablename
enable tablename
4、查看表结构
discribe 'tablename'
5、修改表结构
三、表数据的增删改查
1、添加数据
-
不指定column的名字
put 't1','r1','f1','v1'
-
指定column的名字
put 't1', 'r4', 'f1:c1', 'v1'
2、查询数据
get 'tablename,'r1'
get 'tablename','r1','cf:column
get 'scores', 'r1', {COLUMN=>'cf:column'}
3、扫描表
语法:scan <table>, {COLUMNS => [ family:column,.... ], LIMIT => num}
scan 'tablename,{LIMIT=>5}'
scan 'tablename',{COLUMN=>'cf'}
scan 'tablename',{COLUMN=>'cf:name'}
4、查询行数
INTERVAL设置多少行显示一次及对应的rowkey,默认1000;CACHE每次去取的缓存区大小,默认是10,调整该参数可提高查询速度# 例如,查询表t1中的行数,每100条显示一次,缓存区为500
hbase(main)> count 't1', {INTERVAL => 100, CACHE => 500}
5、删除数据
-
删除行中的某一个列值
语法:delete <table>, <rowkey>, family:column , <timestamp>,必须指定列名
delete 'tablename','r1',cf:column'
-
删除行
语法:deleteall <table>, <rowkey>, family:column , <timestamp>
deleteall't1','rowkey001'
-
删除所有数据disable table -> drop table -> create table
语法: truncate <table> ,原理:
truncate 't1'
6、查看版本
versiion
7、查看状态
status