文章详情

短信预约-IT技能 免费直播动态提醒

请输入下面的图形验证码

提交验证

短信预约提醒成功

Hbase shell操作总结

2024-04-02 19:55

关注

进入hbase命令行 
./hbase shell

显示hbase中的表 
list

创建user表,包含info、data两个列族 
create ‘users’, ‘info’, ‘data’ 
//you can also use this command: 
// create ‘users’, {NAME => ‘info’, VERSIONS => ‘3’}

向表中插入信息,row key为rk0001,列族info中添加name列标示符,值为zhangsan 
put ‘users’, ‘rk0001’, ‘info:name’, ‘zhangsan’

向表中插入信息,row key为rk0001,列族info中添加gender列标示符,值为female 
put ‘user’, ‘rk0001’, ‘info:gender’, ‘female’

向表中插入信息,row key为rk0001,列族info中添加age列标示符,值为20 
put ‘user’, ‘rk0001’, ‘info:age’, 21

获取表中row key为rk0001的所有信息 
get ‘user’, ‘rk0001’

获取表中row key为rk0001,info列族的所有信息 
get ‘user’, ‘rk0001’, ‘info’

获取user表中row key为rk0001,info列族的name、age列标示符的信息 
get ‘user’, ‘rk0001’, ‘info:name’, ‘info:age’

获取user表中row key为rk0001,info、data列族的信息 
get ‘USERS’, ‘rk0001’, ‘INFO’, ‘DATA’ 
get ‘user’, ‘rk0001’, {COLUMN => [‘info’, ‘data’]}

get ‘user’, ‘rk0001’, {COLUMN => [‘info:name’, ‘data:pic’]}

获取user表中row key为rk0001,列族为info,版本号最新5个的信息 
get ‘user’, ‘rk0001’, {COLUMN => ‘info’, VERSIONS => 2} 
get ‘user’, ‘rk0001’, {COLUMN => ‘info:name’, VERSIONS => 5} 
get ‘user’, ‘rk0001’, {COLUMN => ‘info:name’, VERSIONS => 5, TIMERANGE => [1392368783980, 1392380169184]}

获取user表中row key为rk0001,cell的值为zhangsan的信息 
get ‘people’, ‘rk0001’, {FILTER => “ValueFilter(=, ‘binary:图片’)”}

获取user表中row key为rk0001,列标示符中含有a的信息 
get ‘people’, ‘rk0001’, {FILTER => “(QualifierFilter(=,’substring:a’))”}

put ‘user’, ‘rk0002’, ‘info:name’, ‘fanbingbing’ 
put ‘user’, ‘rk0002’, ‘info:gender’, ‘female’ 
put ‘user’, ‘rk0002’, ‘info:nationality’, ‘中国’ 
get ‘user’, ‘rk0002’, {FILTER => “ValueFilter(=, ‘binary:中国’)”}

查询user表中的所有信息 
scan ‘user’

查询user表中列族为info的信息 
scan ‘user’, {COLUMNS => ‘info’} 
scan ‘user’, {COLUMNS => ‘info’, RAW => true, VERSIONS => 5} 
scan ‘persion’, {COLUMNS => ‘info’, RAW => true, VERSIONS => 3} 
查询user表中列族为info和data的信息 
scan ‘user’, {COLUMNS => [‘info’, ‘data’]} 
scan ‘user’, {COLUMNS => [‘info:name’, ‘data:pic’]}

查询user表中列族为info、列标示符为name的信息 
scan ‘user’, {COLUMNS => ‘info:name’}

查询user表中列族为info、列标示符为name的信息,并且版本最新的5个 
scan ‘user’, {COLUMNS => ‘info:name’, VERSIONS => 5}

查询user表中列族为info和data且列标示符中含有a字符的信息 
scan ‘user’, {COLUMNS => [‘info’, ‘data’], FILTER => “(QualifierFilter(=,’substring:a’))”}

查询user表中列族为info,rk范围是[rk0001, rk0003)的数据 
scan ‘people’, {COLUMNS => ‘info’, STARTROW => ‘rk0001’, ENDROW => ‘rk0003’}

查询user表中row key以rk字符开头的 
scan ‘user’,{FILTER=>”PrefixFilter(‘rk’)”}

查询user表中指定范围的数据 
scan ‘user’, {TIMERANGE => [1392368783980, 1392380169184]}

删除数据 
删除user表row key为rk0001,列标示符为info:name的数据 
delete ‘people’, ‘rk0001’, ‘info:name’ 
删除user表row key为rk0001,列标示符为info:name,timestamp为1392383705316的数据 
delete ‘user’, ‘rk0001’, ‘info:name’, 1392383705316

清空user表中的数据 
truncate ‘people’

修改表结构 
首先停用user表(新版本不用) 
disable ‘user’

添加两个列族f1和f2 
alter ‘people’, NAME => ‘f1’ 
alter ‘user’, NAME => ‘f2’ 
启用表 
enable ‘user’

disable ‘user’(新版本不用) 
删除一个列族: 
alter ‘user’, NAME => ‘f1’, METHOD => ‘delete’ 或 alter ‘user’, ‘delete’ => ‘f1’

添加列族f1同时删除列族f2 
alter ‘user’, {NAME => ‘f1’}, {NAME => ‘f2’, METHOD => ‘delete’}

将user表的f1列族版本号改为5 
alter ‘people’, NAME => ‘info’, VERSIONS => 5 
启用表 
enable ‘user’

删除表 
disable ‘user’ 
drop ‘user’

get ‘person’, ‘rk0001’, {FILTER => “ValueFilter(=, ‘binary:中国’)”} 
get ‘person’, ‘rk0001’, {FILTER => “(QualifierFilter(=,’substring:a’))”} 
scan ‘person’, {COLUMNS => ‘info:name’} 
scan ‘person’, {COLUMNS => [‘info’, ‘data’], FILTER => “(QualifierFilter(=,’substring:a’))”} 
scan ‘person’, {COLUMNS => ‘info’, STARTROW => ‘rk0001’, ENDROW => ‘rk0003’}

scan ‘person’, {COLUMNS => ‘info’, STARTROW => ‘20140201’, ENDROW => ‘20140301’} 
scan ‘person’, {COLUMNS => ‘info:name’, TIMERANGE => [1395978233636, 1395987769587]} 
delete ‘person’, ‘rk0001’, ‘info:name’

alter ‘person’, NAME => ‘ffff’ 
alter ‘person’, NAME => ‘info’, VERSIONS => 10

get ‘user’, ‘rk0002’, {COLUMN => [‘info:name’, ‘data:pic’]}


阅读原文内容投诉

免责声明:

① 本站未注明“稿件来源”的信息均来自网络整理。其文字、图片和音视频稿件的所属权归原作者所有。本站收集整理出于非商业性的教育和科研之目的,并不意味着本站赞同其观点或证实其内容的真实性。仅作为临时的测试数据,供内部测试之用。本站并未授权任何人以任何方式主动获取本站任何信息。

② 本站未注明“稿件来源”的临时测试数据将在测试完成后最终做删除处理。有问题或投稿请发送至: 邮箱/279061341@qq.com QQ/279061341

软考中级精品资料免费领

  • 历年真题答案解析
  • 备考技巧名师总结
  • 高频考点精准押题
  • 2024年上半年信息系统项目管理师第二批次真题及答案解析(完整版)

    难度     813人已做
    查看
  • 【考后总结】2024年5月26日信息系统项目管理师第2批次考情分析

    难度     354人已做
    查看
  • 【考后总结】2024年5月25日信息系统项目管理师第1批次考情分析

    难度     318人已做
    查看
  • 2024年上半年软考高项第一、二批次真题考点汇总(完整版)

    难度     435人已做
    查看
  • 2024年上半年系统架构设计师考试综合知识真题

    难度     224人已做
    查看

相关文章

发现更多好内容

猜你喜欢

AI推送时光机
位置:首页-资讯-数据库
咦!没有更多了?去看看其它编程学习网 内容吧
首页课程
资料下载
问答资讯