大数据HBase系列之HBase基本操作

1.  hbase命令

  • 版本查看

hbase version

  • 连接Zookeeper客户端

hbase zkcli

  • 连接HBase客户端

hbase shell


2.  CRUD

2.1  创建表

-- 语法:create '表名','列族名'
create 'student','info'

2.2  显示所有表

-- 语法:list 或 list '表名'
list 'student'

2.3  显示表描述

-- 语法:describe '表名'
describe 'student'

2.4  插入数据

-- 语法:put '表名','行键','列族:列名','值'
put 'student','10001','info:id','Ao001'
put 'student','10001','info:name','Jack'
put 'student','10001','info:sex','man'

put 'student','10002','info:id','Ao002'
put 'student','10002','info:name','Little Blue'
put 'student','10002','info:sex','man'

put 'student','10003','info:id','Ao003'
put 'student','10003','info:name','Laugh laugh'
put 'student','10003','info:sex','woman'

2.5  查询数据

  • get查询
-- 语法:get '表名','行键名'
get 'student','10001'

-- 语法:get '表名','行键名','列族:列名'
get 'student','10002','info:name'
  • scan查询
-- 语法:scan '表名',{COLUMN => ['列族:列名','列族:列名']}
scan 'student',{COLUMN => ['info:name','info:sex']}

-- 语法:scan '表名',{STARTROW =>'条件'}
scan 'student',{STARTROW =>'10002'}

2.6  删除数据

  • delete删除
-- 语法:delete '表名','行键','列族:列名'
delete 'student','10002','info:sex'
  • deleteall删除
-- 语法:deleteall '表名','行键'
deleteall 'student','10003'

 

©️2020 CSDN 皮肤主题: 编程工作室 设计师:CSDN官方博客 返回首页