Hbase shell操作表
Java api 操作(增删改查,过滤等):https://www.cnblogs.com/asker009/p/10626508.html
启动hbase shell
./bin/hbase shell
1、创建表,查看表
create 'tableName', 'familykey1','familykey2',.... eg. create 'student','info','course'
create 'student',{NAME=>'cf',VERSIONS=>1,BLOCKCACHE=>true,BLOOMFILTER=>'ROW',COMPRESSION=>'SNAPPY'},{SPLITS => ['1','2','3']}
list #查看表
2、查看表信息
desc 'student'
3、 修改表结构
alter 'student',{'NAME'=>'course','VERSIONS'=>'3'}
4、insert数据到表中
table-->student rowkey-->201601 familykey:column-->info:name 4:timestamp put 'tableName' ,'rowkey','familykey:column' ,'columnValue',timestamp eg. put 'student','201601','info:name','liu',4 put 'student','201601','info:age',15 put 'student','201601','info:sex','nv' put 'student','201601','info:dept','PE'
5、获取数据
get 'tableName','rowkey' eg. get 'student','201601' #获取student表中rowkey为201601的所有列族数据 get 'student','201601','info:name' #获取student表中rowkey为201601且info列族中name的值
6、更新数据(和插入数据一样,只是少了timestamp)
put 'tableName','rowkey','familykey:column' , 'columnValue'
eg.
put 'student','201601','info:name','yangwj'
7、使用scan进行查询
scan 'student' , {LIMIT =>2} #查看前两条数据
scan 'student',{COLUMN => 'info:dept'} #查询student表中所有列为info:dept的值
scan 'student',FILTER=>"RowFilter(=,'substring:2')" ###查找行带有2的所有字段数据
scan 'student',FILTER=>"ValueFilter(=,'substring:2')" ###查找值带有2的所有字段数据
scan 'student', FILTER=>"ColumnPrefixFilter('birth')" ###列名中的前缀为 birth 的
8、表的快照
snapshot 'student','stu_snap' #创建表的快照 list_snapshots #显示所有快照表 clone_snapshot 'stu_snap','stu_info' #克隆快照从而生成新的表 delete_snapshot 'stu_snap' #删除快照
9、删除表 (先禁用表再删除)
disable 'student' #禁用表 is_disabled 'student' #查看表是否被禁用 true:禁用 drop 'student' #删除表
10、查看数据总条数
count 'student' #查看数据总条数
11、总结
完毕!
可参考链接:https://juejin.im/post/6844903949728759821#heading-22
本文来自博客园,作者:小白啊小白,Fighting,转载请注明原文链接:https://www.cnblogs.com/ywjfx/p/11345291.html