HBase常用命令及使用
来源:互联网 发布:淘宝上的日亚礼品卡 编辑:程序博客网 时间:2024/06/01 15:51
名称命令表达式创建表create '表名称’,'列名称1’,'列名称2’,...'列名称n'添加记录put '表名称’,'行名称',‘值’查看记录get ‘表名称’,‘行名称’查看表的总记录数count ‘表名称’删除记录delete '表名称',‘行名称’,‘列名称’删除表1.disable‘表名称’ 2.drop ‘表名称’ (先要屏蔽表,才能删除表)查看所以记录scan ‘表名称’查看某个表中某列的数据scan ‘表名称’,[‘列名称’]更新记录更新及添加 put '表名称’,'行名称',‘值’
命令操作
创建表
插入/添加数据create 'ns2:user','info','score'
hbase(main):008:0> create 'ns2:user','info','score'0 row(s) in 1.4340 seconds=> Hbase::Table - ns2:user
put 'ns2:user','1','info:name','xiaojian'
put 'ns2:user','1','info:age','20'
put 'ns2:user','1','score:math','78'
=> Hbase::Table - ns2:userhbase(main):009:0> put 'ns2:user','1','info:name','xioajian'0 row(s) in 0.3140 secondshbase(main):010:0> put 'ns2:user','1','info:age','20'0 row(s) in 0.0290 secondshbase(main):011:0> put 'ns2:user','1','score:math','78'0 row(s) in 0.0470 seconds查看所有记录
scan 'ns2:user'
hbase(main):012:0> scan 'ns2:user'ROW COLUMN+CELL 1 column=info:age, timestamp=1502543902061, val ue=20 1 column=info:name, timestamp=1502543891679, va lue=xioajian 1 column=score:math, timestamp=1502543920185, v alue=78 1 row(s) in 0.0920 seconds表描述
describe 'ns2:user'
hbase(main):014:0> describe 'ns2:user'DESCRIPTION ENABLED 'ns2:user', {NAME => 'info', DATA_BLOCK true _ENCODING => 'NONE', BLOOMFILTER => 'RO W', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VERS IONS => '0', TTL => 'FOREVER', KEEP_DEL ETED_CELLS => 'false', BLOCKSIZE => '65 536', IN_MEMORY => 'false', BLOCKCACHE => 'true'}, {NAME => 'score', DATA_BLOC K_ENCODING => 'NONE', BLOOMFILTER => 'R OW', REPLICATION_SCOPE => '0', VERSIONS => '1', COMPRESSION => 'NONE', MIN_VER SIONS => '0', TTL => 'FOREVER', KEEP_DE LETED_CELLS => 'false', BLOCKSIZE => '6 5536', IN_MEMORY => 'false', BLOCKCACHE => 'true'} 1 row(s) in 0.1550 seconds更新表
put 'ns2:user','1','info:name','liuxioajian'
hbase(main):021:0> scan 'ns2:user'ROW COLUMN+CELL 1 column=info:age, timestamp=1502543902061, val ue=20 1 column=info:name, timestamp=1502544557979, va lue=liuxioajian 1 column=score:math, timestamp=1502543920185, v alue=78 1 row(s) in 0.0590 seconds删除记录
delete 'ns2:user','1','info:name'
删除表
drop 'ns2:user'(报错)
hbase(main):022:0> drop 'ns2:user'ERROR: Table ns2:user is enabled. Disable it first.'Here is some help for this command:Drop the named table. Table must first be disabled: hbase> drop 't1' hbase> drop 'ns1:t1'先把表设置为disable
disable 'ns2:user'
hbase(main):001:0> disable 'ns2:user'2017-08-12 21:36:46,499 WARN [main] util.NativeCodeLoader: Unable to load native-hadoop library for your platform... using builtin-java classes where applicable0 row(s) in 15.4270 seconds再删除表
drop ‘ns2:user’hbase(main):002:0> drop 'ns2:user'0 row(s) in 0.7480 seconds查看命名空间下的所有表
list_namespace_tables 'ns2'
hbase(main):012:0> list_namespace_tables 'ns2'TABLE person studentuser表不在,因为上面把表删除了
所以下面又建了张user表
hbase(main):018:0> scan 'ns2:user'ROW COLUMN+CELL 1 column=info:age, timestamp=1502545506778, val ue=20 1 column=info:name, timestamp=1502545498698, va lue=xiaojian 1 column=score:math, timestamp=1502545526200, v alue=90 2 column=info:age, timestamp=1502545829642, val ue=22 2 column=info:name, timestamp=1502545820947, va lue=zhangsan 2 column=score:math, timestamp=1502545807495, v alue=68 2 row(s) in 0.1000 secondsget查询
查一行
get 'ns2:user','2'
hbase(main):019:0> get 'ns2:user','2'COLUMN CELL info:age timestamp=1502545829642, value=22 info:name timestamp=1502545820947, value=zhangsan score:math timestamp=1502545807495, value=68 3 row(s) in 0.0710 seconds
查一行的一列(cell单元)
get 'ns2:user','2','info:name'
hbase(main):020:0> get 'ns2:user','2','info:name'COLUMN CELL info:name timestamp=1502545820947, value=zhangsan 1 row(s) in 0.0330 seconds查询表的总记录数
count 'ns2:user'
hbase(main):021:0> count 'ns2:user'2 row(s) in 0.0730 seconds=> 2命名空间
创建命名空间 create_namespace 'ns3'
查看命名空间 list_namespace
hbase(main):024:0> list_namespaceNAMESPACE default hbase ns1 ns2 ns3 5 row(s) in 0.0790 seconds
阅读全文
0 0
- HBase常用命令及使用
- Hbase简介及常用命令
- HBase Shell 常用命令及例子
- HBase Shell 常用命令及例子
- HBase Shell 常用命令及例子
- HBase Shell 常用命令及例子
- HBase Shell 常用命令及例子
- hbase运维常用命令及相关说明
- HBase总结(十三)HBase Shell 常用命令及例子
- HBase总结(十三)HBase Shell 常用命令及例子
- HBase总结(十三)HBase Shell 常用命令及例子
- HBase总结(十三)HBase Shell 常用命令及例子
- HBase总结(十三)HBase Shell 常用命令及例子
- HBase常用命令
- hbase常用命令
- Hbase常用命令
- Hbase常用命令
- Hbase - 常用命令
- 51nod 1515 明辨是非(合并并查集)
- Dbutils学习(介绍和入门)[转载]
- Android更改源码后编译错误unknown package name of class file
- Spring Bean的生命周期
- Codeforce 839 -- B Game of the Rows 【思维 + 贪心】
- HBase常用命令及使用
- 编程小细节
- String、StringBuffer与StringBuilder之间区别
- dns的辅助和ddns
- Codeforces Round #428 (Div. 2) B.Game of the Rows(贪心+炒鸡多坑的模拟)
- 关于Pyhton logging
- JavaScript趣味编程--仿微信飞机大战游戏--4.飞机重复往下
- pat:1016. 部分A+B (15)
- request.getParameter与Bean的错误