Hadoop之——Hbase Shell命令

转载请注明出处:http://blog.csdn.net/l1028386804/article/details/46463503

HBASE Shell

进入Habse数据库终端:#$HBASE_HOME/bin/hbase shell

技术分享

创建表

>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‘

添加记录

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‘

删除xiaoming值的‘info:age‘字段

>delete ‘users‘,‘xiaoming‘,‘info:age‘

>get ‘users‘,‘xiaoming‘

删除整行

>deleteall ‘users‘,‘xiaoming‘

统计表的行数

>count ‘users‘

清空表

>truncate‘users‘

郑重声明:本站内容如果来自互联网及其他传播媒体,其版权均属原媒体及文章作者所有。转载目的在于传递更多信息及用于网络分享,并不代表本站赞同其观点和对其真实性负责,也不构成任何其他建议。