赞
踩
> hbase shell
> whoami
hbase(main):001:0> list
hbase(main):002:0> create 'student','info'
hbase(main):003:0> put 'student','1001','info:sex','male'
hbase(main):004:0> put 'student','1001','info:age','18'
hbase(main):005:0> put 'student','1002','info:name','Janna'
hbase(main):006:0> put 'student','1002','info:sex','female'
hbase(main):007:0> put 'student','1002','info:age','20'
# 查询表中所有的记录
hbase(main):008:0> scan 'student'
# 只查看某一列的数据
hbase(main):009:0> scan 'student',{{COLUMN=>'info:name'}}
# 只查看某一列族的数据
hbase(main):010:0> scan 'student',{STARTROW => 'info'}
hbase(main):011:0> describe ‘student’
hbase(main):012:0> put 'student','1001','info:name','Nick'
hbase(main):013:0> put 'student','1001','info:age','100'
# 通过Row key查询记录
# get 表名 Row key
hbase(main):014:0> get 'student','1001'
# 通过Row key和列族查询数据
hbase(main):015:0> get 'student','1001','info'
# 通过Row key,列族:列查询数据
hbase(main):016:0> get 'student','1001','info:name'
hbase(main):017:0> count 'student'
hbase(main):018:0> deleteall 'student','1001'
hbase(main):019:0> delete 'student','1002','info:sex'
hbase(main):020:0> truncate 'student'
# 注意:清空表的操作顺序为先 disable,然后再 truncate。
# 首先需要先让该表为 disable 状态:
hbase(main):021:0> disable 'student'
# 然后才能 drop 这个表:
hbase(main):022:0> drop 'student'
# 注意:如果直接 drop 表,会报错:ERROR: Table student is enabled. Disable it first.
Copyright © 2003-2013 www.wpsshop.cn 版权所有,并保留所有权利。