HBase shell 简单使用
增加记录
>put 'blog','1','article:title,' Head First HBase '
>put 'blog','1','article:content','HBase is the Hadoop database. Use it when you need random, realtime read/write access to your Big Data.'
> put 'blog','1','article:tags','Hadoop,HBase,NoSQL'
> put 'blog','1','author:name','hujinjun'
> put 'blog','1','author:nickname',’一叶渡江’
知识点回顾:Column完全动态扩展,每行可以有不同的Columns。
根据RowKey查询
> get 'blog','1'
知识点回顾:HTable按RowKey字典序(1,10,100,11,2)自动排序,每行包含任意数量
的Columns,Columns按ColumnKey(article:content,article:tags,article:title,author:name,author:nickname)自动排序
查询列族
>get 'blog','1','author
查看表内容
>scan 'blog'
更新练习
> get ‘blog’,’1’,’author:nickname’
> put ‘blog’,’1’,’ahthor:nickname’,’yedu’
> get ‘blog’,’1’,’author:nickname’
知识点回顾:查询默认返回最近的值。
> get 'blog','1',{COLUMN => 'author:nickname',VERSIONS => 2}
知识点回顾:每个Column可以有任意数量的Values,按Timestamp倒序自动排序。
当修改多次(大于3次,修改2次时也就有3个VERSIONS)时:VERSIONS默认最高为3
> get 'blog','1',{COLUMN => 'author:nickname',VERSIONS => 4}
>get 'blog','1',{COLUMN => 'author:nickname', TIMESTAMP => 1333690828877}
知识点回顾:TabelName+RowKey+Column+Timestamp=>Value
删除记录
>delete 'blog','1','author:nickname'
>deleteall ‘blog’,’1’
删除表
练习完毕,把练习表删了吧,删除之前需要先disable
>disable ‘blog’
>drop ‘blog’
小结
本文演示了通过HBase shell创建、删除表及对记录的增删改查,可以参照操作结果对回顾的知识点进一步理解掌握,在本系列下一篇文章中讲演示如何通过Java api来与HBase交互。