吴超先生课程

hbase提供了1个shell的终极给用户交互

名称

命令表达式

创建表

create ‘表名称’, ‘列族名称1′,’列族名称2′,’列族名称N’

添加记录      

put ‘表名称’, ‘行名称’, ‘列名称:’, ‘值’

查看记录

get ‘表名称’, ‘行名称’

查看表中的记录总数

count  ‘表名称’

删除记录

delete  ‘表名’ ,’行名称’ , ‘列名称’

删除一张表

先要屏蔽该表,才能对该表进行删除,第一步 disable ‘表名称’ 第二步  drop ‘表名称’

查看所有记录

scan "表名称"  

查看某个表某个列中所有数据

 

            

#$HBASE_HOME/bin/hbase shell
……
>quit

1.HBASE Shell的DDL操作

(1)创建表
>create
‘users’,’user_id’,’address’,’info’
表users,有七个列族user_id,address,info

(二)列出1切表
>list

(三)得到表的描述
wwwlehu6.vip乐虎官网,>describe ‘users’

(4)创建表
>create
‘users_tmp’,’user_id’,’address’,’info’

(5)删除表
>disable ‘users_tmp’
>drop ‘users_tmp’

2.HBASE Shell的DML操作

加上记录
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’;        
(address是列族,county是列,正是标签,)
put ‘users’,’xiaoming’,’address:province’,’zhejiang’;
(address是列族,province是列,正是标签,)
put ‘users’,’xiaoming’,’address:city’,’hangzhou’;     
(address是列族,city是列,正是标签,)
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’;
获得一条记下
(一).取得3个id的具有数据
>get ‘users’,’xiaoming’
(2).获取二个id,三个列族的具备数据
>get ‘users’,’xiaoming’,’info’
(3).获取3个id,贰个列族中2个列的有着数据
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’

 

You can leave a response, or trackback from your own site.

Leave a Reply

网站地图xml地图