hbase常用命令

启动HBase

start-hbase.sh

进入HBase客户端命令

bin/hbase shell

所有命令帮助

help 

命令分几类(有省略)

Group name: ddl

Commands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, 

get_table, is_disabled, is_enabled, list, list_regions, locate_region, show_filters

Group name: namespace

Commands: alter_namespace, create_namespace, describe_namespace, drop_namespace, list_namespace, list_namespace_tables

Group name: dml

Commands: append, count, delete, deleteall, get, get_counter, get_splits, incr, put, scan, truncate, truncate_preserve

1、namespace

查看命名空间

list_namespace

用法

list_namespace

list_namespace 'abc.*'

创建命名空间

create_namespace '命名空间名'

create_namespace 'ns1', {'PROPERTY_NAME'=>'PROPERTY_VALUE'}

2、ddl

查看表格

list

创建表格

create '命名空间名:表名', {NAME => '列族名', VERSIONS => 版本号}

create 'norma:t1', {NAME => 'f1', VERSIONS => 5}

create 't1', {NAME => 'f1'}, {NAME => 'f2'}, {NAME => 'f3'}

create 't1', 'f1', 'f2', 'f3'

查看表格详细信息

describe '命名空间名:表名'

修改表

修改字段

alter 't1', 'f1', {NAME => 'f2', IN_MEMORY => true}, {NAME => 'f3', VERSIONS => 5}

修改操作中可以删除

alter 'ns1:t1', NAME => 'f1', METHOD => 'delete'

alter 'ns1:t1', 'delete' => 'f1'

删除表

首先禁用该表

disable '命名空间名:表名'

再删除该表

drop '命名空间名:表名'

3、dml

写入数据

put '命名空间名:表名', 'rowkey(行号)', '列族名:列名', 'value'

put 'ns1:t1', 'r1', 'c1', 'value'

重复写入相同的rowKey,相同列的数据,会写入多个版本进行覆盖

读取一行数据

get 

get '命名空间名:表名', 'rowkey(行号)'

get 'ns1:t1', 'r1'

get 't1', 'r1', {COLUMN => ['c1', 'c2', 'c3']}

读取多个版本的数据

get 't1', 'r1', {COLUMN => 'c1', VERSIONS => 4}

读取多行数据

scan

scan '命名空间名:表名'

scan 'ns1:t1'

scan 'ns1:t1', {COLUMNS => ['c1', 'c2'], LIMIT => 10, STARTROW => 'xyz'}

推荐使用STARTROW和stopRow来控制数据读取,默认范围左闭右开。

scan 'ns1:t1', {STARTROW => '1001', STOPROW => '1005'}

删除数据

delete

get '命名空间名:表名', 'rowkey(行号)', '字段名', '时间戳'

会删除时间戳小的最接近的一个版本的数据,时间戳可以省略,若省略则为当前时间

delete 'ns1:t1', 'r1', 'c1', ts1

deletall

删除所有版本的数据

deleteall 'ns1:t1', 'r1', 'c1'

查看hbase所有的表:list

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值