- HBase是一个分布式的、面向列的开源数据库
- 利用Hadoop HDFS作为其文件存储系统,
- 利用Hadoop MapReduce来处理HBase中的海量数据
create 'myscore','name','info'
put 'myscore','row1','name','xiaohong'
put 'myscore','row1','info:age',18
put 'myscore','row1','info:address','changchun'
get 'myscore','row1'
get 'myscore','row1','name'
get 'myscore','row1','info:age'
get 'myscore','row1',{COLUMN=>['info:age','name']}
scan 'myscore'
disable 'myscore'
drop 'myscore'
创建列族时指定VERSIONS=>n,用于保存最近的n条历史记录
(不指定时默认versions=>1)
查询时指定VERSIONS=>n,用于查看最近的n条历史记录
(scan table 始终是扫描表的每一行的最大版本对应的记录,即最新的记录)
hbase(main):023:0> create 'newuser',{NAME=>'name',VERSIONS=>5}
0 row(s) in 0.3860 seconds
=> Hbase::Table - newuser
hbase(main):024:0> put 'newuser','row1','name','tutu1'
0 row(s) in 0.0300 seconds
hbase(main):025:0> put 'newuser','row1','name','tutu2'
0 row(s) in 0.0040 seconds
hbase(main):026:0> put 'newuser','row1','name','tutu3'
0 row(s) in 0.0070 seconds
hbase(main):027:0> get 'newuser','row1',{COLUMN=>'name',VERSIONS=>2}
COLUMN CELL
name: timestamp=1574383699752, value=tutu3
name: timestamp=1574383695565, value=tutu2
2 row(s) in 0.0080 seconds
hbase(main):028:0> get 'newuser','row1',{COLUMN=>'name',VERSIONS=>1}
COLUMN CELL
name: timestamp=1574383699752, value=tutu3
1 row(s) in 0.0180 seconds
hbase(main):029:0> get 'newuser','row1',{COLUMN=>'name',VERSIONS=>3}
COLUMN CELL
name: timestamp=1574383699752, value=tutu3
name: timestamp=1574383695565, value=tutu2
name: timestamp=1574383692059, value=tutu1
3 row(s) in 0.0090 seconds
hbase(main):030:0> get 'newuser','row1',{COLUMN=>'name',VERSIONS=>4}
COLUMN CELL
name: timestamp=1574383699752, value=tutu3
name: timestamp=1574383695565, value=tutu2
name: timestamp=1574383692059, value=tutu1
3 row(s) in 0.0070 seconds
hbase(main):031:0>
create 'mytable', {NAME =>'info', VERSIONS=>3}, {NAME=>'data', VERSIONS=>1}
count ‘mytable’返回记录数
删除rowkey为rk1的值的记录deleteall 'mytable','rk1'
删除rowkey为rk2的值的‘info:gender’字段delete 'mytable','rk2','info:gender'
查询表中前3条数据。执行命令scan 'mytable', {LIMIT=>3}
查看表中某个列中的所有数据scan 'mytable', {COLUMN=>'info:name'}
查询指定行列数据get 'mytable', 'rk1', {COLUMN=>'info:name'}