1、HBase提供了一个shell的终端给用户交互
2、HBase Shell的DDL操作
(1)先进入HBase的 Shell命令行,即HBASE_HOME/bin/hbase shell …… >quit
创建表: >create 'users','user_id','address','info' //表users,有三个列族user_id,address,info 列出全部表: >list 得到表的描述: >describe 'users'创建表: >create 'users_tmp','user_id','address','info'删除表: >disable 'users_tmp' >drop 'users_tmp'
(2)添加记录、获取记录、更新记录
添加记录: put 'users','xiaoming','info:age','24'; put 'users','xiaoming','info:birthday','1987-06-17'; put 'users','xiaoming','info:company','alibaba'; put 'users','xiaoming','address:contry','china'; put 'users','xiaoming','address:province','zhejiang'; put 'users','xiaoming','address:city','hangzhou'; put 'users','zhangyifei','info:birthday','1987-4-17'; put 'users','zhangyifei','info:favorite','movie'; put 'users','zhangyifei','info:company','alibaba'; put 'users','zhangyifei','address:contry','china'; put 'users','zhangyifei','address:province','guangdong'; put 'users','zhangyifei','address:city','jieyang'; put 'users','zhangyifei','address:town','xianqiao';获取一条记录:1.取得一个id的所有数据: >get 'users','xiaoming'2.获取一个id,一个列族的所有数据: >get 'users','xiaoming','info'3.获取一个id,一个列族中一个列的:所有数据 get 'users','xiaoming','info:age'
更新记录: >put 'users','xiaoming','info:age' ,'29' >get 'users','xiaoming','info:age' >put 'users','xiaoming','info:age' ,'30' >get 'users','xiaoming','info:age'获取单元格数据的版本数据: >get 'users','xiaoming',{COLUMN=>'info:age',VERSIONS=>1} >get 'users','xiaoming',{COLUMN=>'info:age',VERSIONS=>2} >get 'users','xiaoming',{COLUMN=>'info:age',VERSIONS=>3}获取单元格数据的某个版本数据 〉get 'users','xiaoming', {COLUMN=>'info:age',TIMESTAMP=>1364874937056}全表扫描: >scan 'users'
(3)删除
删除xiaoming值的'info:age'字段: >delete 'users','xiaoming','info:age' >get 'users','xiaoming'删除整行: >deleteall 'users','xiaoming'统计表的行数: >count 'users'清空表: >truncate 'users'