HBase Shell 工具
基本命令
hbase(main):001:0> help
help 'create_namespace' 查看命令的用法
namespace 创建 查看 描述 删除
create_namespace 'ns_name'
list_namespace
describe_namespace 'student'
drop_namespace 'ns_name'
table
创建 默认是default的namespacehbase 注意:创建表时必须指定表名及列簇
create 't1', 'f1', 'f2', 'f3'
create 'student:stu_info', 'info'
查看 list
ns_name:tb_name :唯一确定一张表,除默认namespace
描述 desc 'student:stu_info'或describe 'student:stu_info'
删除 企业中规范:-》删除时必须先禁用表 修改表,先禁用-修改-启用
表的DML
增 rowkey的设计比较重要
put 'ns1:t1', 'r1', 'c1', 'value'
put 'student:stu_info','20161204_1001','info:name','laosi'
put 'student:stu_info','20161204_1001','info:age','18'
put 'student:stu_info','20161204_1001','info:sex','male'
put 'student:stu_info','20161204_1002','info:name','laoer'
put 'student:stu_info','20161204_1002','info:age','20'
put 'student:stu_info','20161204_1003','info:name','laosan'
put 'student:stu_info','20161204_1003','info:age','22'
查 get :查询最快的方式,必须指定rowkey
get 'student:stu_info','20161204_1001'
scan:全局扫描,企业中不常用 scan 'student:stu_info'
scan+ 过滤:企业中最常用的方式,速度仅次于get
scan 'student:stu_info',{STARTROW=>'20161204_1001'}
scan 'student:stu_info',{STARTROW=>'20161204_1001',STOPROW=>'20161204_1002'}
包头不包尾
删
delete 'student:stu_info','20161204_1003','info:name'
deleteall支持按照rowkey删除
改 hbase中没有改的概念
put 'student:stu_info','20161204_1001','info:name','laoda'
网友评论