• 【HBase】 常用命令


    创建表

    hbase(main):006:0> create 'goods_zc','type'
    0 row(s) in 1.3090 seconds
    
    => Hbase::Table - goods_zc
    

    删除表

    hbase(main):008:0> disable 'goods_zc'
    0 row(s) in 2.4100 seconds
    
    hbase(main):009:0> drop 'goods_zc'
    0 row(s) in 1.2780 seconds
    

    添加数据

    
    hbase(main):014:0> put 'goods_zc','1001','info:type','fruit'
    0 row(s) in 0.0370 seconds
    
    hbase(main):015:0> put 'goods_zc','1001','info:discount','0.8'
    0 row(s) in 0.0250 seconds
    
    hbase(main):016:0> put 'goods_zc','1001','address:where','wuhan'
    0 row(s) in 0.0360 seconds
    
    hbase(main):017:0> put 'goods_zc','1001','info:name','banana'
    0 row(s) in 0.0150 seconds
    
    hbase(main):018:0> put 'goods_zc','1003','info:name','carrot'
    0 row(s) in 0.0280 seconds
    
    hbase(main):019:0> put 'goods_zc','1003','info:type','vegetable'
    0 row(s) in 0.0270 seconds
    
    hbase(main):020:0> put 'goods_zc','1003','info:kind','high-quality'
    0 row(s) in 0.0140 seconds
    
    hbase(main):021:0> put 'goods_zc','1003','info:discount','2'
    0 row(s) in 0.0320 seconds
    
    hbase(main):022:0> put 'goods_zc','1006','info:name','bear'
    0 row(s) in 0.0220 seconds
    
    hbase(main):023:0> put 'goods_zc','1006','info:price','25'
    0 row(s) in 0.0130 seconds
    
    hbase(main):024:0> put 'goods_zc','1006','info:object','5'
    0 row(s) in 0.0180 seconds
    
    hbase(main):025:0> put 'goods_zc','1006','info:material','cotton'
    0 row(s) in 0.0210 seconds
    
    hbase(main):026:0> put 'goods_zc','1002','info:name','cat'
    0 row(s) in 0.0390 seconds
    
    hbase(main):027:0> put 'goods_zc','1004','info:name','fmvp'
    0 row(s) in 0.0160 seconds
    
    hbase(main):028:0> put 'goods_zc','1005','info:name','hero'
    0 row(s) in 0.0280 seconds
    
    hbase(main):029:0> put 'goods_zc','1007','info:name','ag'
    0 row(s) in 0.0150 seconds
    
    hbase(main):030:0> put 'goods_zc','1008','info:name','rgm'
    0 row(s) in 0.0170 seconds
    
    hbase(main):031:0> put 'goods_zc','1009','info:name','qghappy'
    0 row(s) in 0.0140 seconds
    
    hbase(main):032:0> put 'goods_zc','1010','info:name','中文测试'
    0 row(s) in 0.0190 seconds
    
    

    查看全表

    hbase(main):033:0> scan 'goods_zc'
    ROW                                                 COLUMN+CELL                                                                                                                                          
     1001                                               column=address:where, timestamp=1570790847160, value=wuhan                                                                                           
     1001                                               column=info:discount, timestamp=1570790813784, value=0.8                                                                                             
     1001                                               column=info:name, timestamp=1570790933889, value=banana                                                                                              
     1001                                               column=info:type, timestamp=1570790756853, value=fruit                                                                                               
     1002                                               column=info:name, timestamp=1570791810946, value=cat                                                                                                 
     1003                                               column=info:discount, timestamp=1570791425426, value=2                                                                                               
     1003                                               column=info:kind, timestamp=1570791409436, value=high-quality                                                                                        
     1003                                               column=info:name, timestamp=1570791369714, value=carrot                                                                                              
     1003                                               column=info:type, timestamp=1570791382735, value=vegetable                                                                                           
     1004                                               column=info:name, timestamp=1570791822468, value=fmvp                                                                                                
     1005                                               column=info:name, timestamp=1570791838620, value=hero                                                                                                
     1006                                               column=info:material, timestamp=1570791478499, value=cotton                                                                                          
     1006                                               column=info:name, timestamp=1570791438023, value=bear                                                                                                
     1006                                               column=info:object, timestamp=1570791465164, value=5                                                                                                 
     1006                                               column=info:price, timestamp=1570791451505, value=25                                                                                                 
     1007                                               column=info:name, timestamp=1570791847743, value=ag                                                                                                  
     1008                                               column=info:name, timestamp=1570791857292, value=rgm                                                                                                 
     1009                                               column=info:name, timestamp=1570791868258, value=qghappy                                                                                             
     1010                                               column=info:name, timestamp=1570791877643, value=xE4xB8xADxE6x96x87xE6xB5x8BxE8xAFx95                                                    
    10 row(s) in 0.0710 seconds
    
    

    变量

    hbase(main):045:0> t=get_table 'goods_zc'
    0 row(s) in 0.0000 seconds
    
    => Hbase::Table - goods_zc
    hbase(main):046:0> t.get '1001'
    COLUMN                                              CELL                                                                                                                                                 
     address:where                                      timestamp=1570790847160, value=wuhan                                                                                                                 
     info:discount                                      timestamp=1570792094524, value=8.5                                                                                                                   
     info:name                                          timestamp=1570790933889, value=banana                                                                                                                
     info:type                                          timestamp=1570790756853, value=fruit                                                                                                                 
    4 row(s) in 0.0210 seconds
    
    

    条件查看

    hbase(main):050:0> scan 'goods_zc',{LIMIT=>3,STARTROW=>'1006'}
    ROW                                                 COLUMN+CELL                                                                                                                                          
     1006                                               column=info:material, timestamp=1570791478499, value=cotton                                                                                          
     1006                                               column=info:name, timestamp=1570791438023, value=bear                                                                                                
     1006                                               column=info:object, timestamp=1570791465164, value=5                                                                                                 
     1006                                               column=info:price, timestamp=1570791451505, value=25                                                                                                 
     1007                                               column=info:name, timestamp=1570791847743, value=ag                                                                                                  
     1008                                               column=info:name, timestamp=1570791857292, value=rgm                                                                                                 
    3 row(s) in 0.0340 seconds
    
    
  • 相关阅读:
    Centos7开机启动脚本代码
    浏览器标签上的 favicon 图标是怎么实现的?
    Android添加权限大讲解
    一个安卓小项目(3)——安卓FTP方式发送文件到服务器
    一个安卓小项目(2)——各模块具体流程
    XML中特殊符号转义实体
    Android Activity生命周期
    牛是怎么死的原文+感想
    一个安卓小项目(1)——需求与分工
    不忘初心
  • 原文地址:https://www.cnblogs.com/BIG-BOSS-ZC/p/11807303.html
Copyright © 2020-2023  润新知