DDL command table of basic operations hbase

  1. HBase is a distributed, column-oriented open source database
  2. Hadoop HDFS use as a file storage system,
  3. Hadoop MapReduce to use massive data in 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'

Specified when creating the column family VERSIONS => n, save for the recent history of n
(default is not specified versions => 1)
specified VERSIONS query => n, n for viewing recent history records
(scan table always is the largest version of the record corresponding to each line scan the table, that the latest record)

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'}
Published 10 original articles · won praise 5 · Views 925

Guess you like

Origin blog.csdn.net/qq_42774323/article/details/103198997