hbase常用命令总结

时间:2023-02-15 00:28:00

创建表:
表名:csliyb:testuser
列族:name

例子:create 'csliyb:testuser','name','age'

添加记录:

put 'csliyb:testuser','10001','name:name','zhangsan'
put 'csliyb:testuser','10002','name:name','lisi'
put 'csliyb:testuser','10003','name:name','wangwu'
put 'csliyb:testuser','10004','name:name','zhaoliu'

put 'csliyb:testuser','10001','age:age','16'
put 'csliyb:testuser','10002','age:age','20'
put 'csliyb:testuser','10003','age:age','25'
put 'csliyb:testuser','10004','age:age','30'

查看某行记录:
表明:csliyb:testuser
行号:10001

例子:get 'csliyb:testuser','10001'

更新记录:
(更新记录和添加记录是一样的,差得新纪录会覆盖老的记录)

表明:csliyb:testuser
行号:10001
列族:age:age
value:16

例子:put 'csliyb:testuser','10001','age:age','16'

获取某行某列族的数据
表名:csliyb:sum_day_city
行号:83210_20160130
列族:tourist_sum:sum_attr_prov

例子:get 'csliyb:sum_day_city','83210_20160130','tourist_sum:sum_attr_prov'

删除行:

deleteall 'csliyb:sum_day_scenic','83502000002_20151231'

清空表:

truncate 'csliyb:sum_mon_scenic'

查询整月数据:
scan 'csliyb:griphbase',{FILTER=>"PrefixFilter('0592_118090024440040_201512')",VERSIONS=>100}

添加列族
disable 'csliyb:sum_day_city'
alter 'csliyb:sum_day_city', NAME => 'tourist_sum_whole_net', VERSIONS =>3
enable 'csliyb:sum_day_city'

查看表结构
describe 'csliyb:sum_day_city'

分页查询:

scan 'proripc:area',{LIMIT=>20}