• HBase的Shell命令


    1、HBase提供了一个shell的终端给用户交互

    2、HBase Shell的DDL操作

    (1)先进入HBase的 Shell命令行,即HBASE_HOME/bin/hbase shell …… >quit

    创建表:
        >create 'users','user_id','address','info'    //表users,有三个列族user_id,address,info

    列出全部表: >list 得到表的描述: >describe 'users' 创建表: >create 'users_tmp','user_id','address','info' 删除表: >disable 'users_tmp' >drop 'users_tmp'

    (2)添加记录、获取记录、更新记录

    添加记录:
        put 'users','xiaoming','info:age','24';
        put 'users','xiaoming','info:birthday','1987-06-17';
        put 'users','xiaoming','info:company','alibaba';
        put 'users','xiaoming','address:contry','china';
        put 'users','xiaoming','address:province','zhejiang';
        put 'users','xiaoming','address:city','hangzhou';
        put 'users','zhangyifei','info:birthday','1987-4-17';
        put 'users','zhangyifei','info:favorite','movie';
        put 'users','zhangyifei','info:company','alibaba';
        put 'users','zhangyifei','address:contry','china';
        put 'users','zhangyifei','address:province','guangdong';
        put 'users','zhangyifei','address:city','jieyang';
        put 'users','zhangyifei','address:town','xianqiao';
    
    获取一条记录:
    1.取得一个id的所有数据:
        >get 'users','xiaoming'
    
    2.获取一个id,一个列族的所有数据:
        >get 'users','xiaoming','info'
    
    3.获取一个id,一个列族中一个列的:
    所有数据
        get 'users','xiaoming','info:age'
    更新记录:
        >put 'users','xiaoming','info:age' ,'29'
        >get 'users','xiaoming','info:age'
        >put 'users','xiaoming','info:age' ,'30'
        >get 'users','xiaoming','info:age'
    获取单元格数据的版本数据:
        >get 'users','xiaoming',{COLUMN=>'info:age',VERSIONS=>1}
        >get 'users','xiaoming',{COLUMN=>'info:age',VERSIONS=>2}
        >get 'users','xiaoming',{COLUMN=>'info:age',VERSIONS=>3}
    获取单元格数据的某个版本数据
        〉get 'users','xiaoming',  {COLUMN=>'info:age',TIMESTAMP=>1364874937056}
    全表扫描:
        >scan 'users'

    (3)删除

    删除xiaoming值的'info:age'字段:
        >delete 'users','xiaoming','info:age'
        >get 'users','xiaoming'
    删除整行:
        >deleteall 'users','xiaoming'
    统计表的行数:
        >count 'users'
    清空表:
        >truncate 'users'
  • 相关阅读:
    Linux Shell的18条常用命令整理
    git branch 命令查看分支、删除远程分支、本地分支
    比Xshel更好用的 FinalShell
    Centos7的目录结构
    准确率(Accuracy), 精确率(Precision), 召回率(Recall)和F1-Measure
    代码托管仓库之码云
    包管理工具之Pipenv
    Python的垃圾回收机制
    Django之Models操作
    Python操作数据库实战
  • 原文地址:https://www.cnblogs.com/chamie/p/4735048.html
Copyright © 2020-2023  润新知