hbase常用shell命令

hbase建表:

create 'test:medication',  {NAME=>'p'}

其中test是表空间,hbase表名是medication,列族是p

添加数据:

 put 'test:medication','2','p:ICD_CODE','B23'

向hbase中添加数据,rowkey是2

按照rowkey进行模糊查询:

scan ‘ihr:HealthExam_Reg’,{FILTER=>org.apache.hadoop.hbase.filter.PrefixFilter.new(org.apache.hadoop.hbase.util.Bytes.toBytes(‘pk_350203198909142016’))}

查询前几条数据:

scan 'test:medication',{LIMIT=>5}

hbase 删除表数据 :

truncate "test:medication"

查询条数:

count "ihr:sehr_xman_event"

count表时,默认是1000条可以通过修改INTERVAL更改查询条数:

count 'test:ming', INTERVAL => 100000

hbase大表数据通过MapReduce快速count计数:

$HBASE_HOME/bin/hbase org.apache.hadoop.hbase.mapreduce.RowCounter 'tablename'

删除表
分两步:首先disable,然后drop
删除表test:medication

disable 'test:medication'

 drop 'test:medication'

hbase查看表大小:

hadoop fs -du -s -h /apps/hbase/data/data/你的表空间/你的表名

hbase更改表名
因为hbase中没有rename命令,所以在更改的时候比较复杂。hbase表重命名主要是通过hbase的快照功能实现的。

1.停止表继续插入 hbase shell>disable 'tableName'

2.制作快照  hbase shell>snapshot 'tableName','tableSnapshot'	

3.克隆快照为新的名字 hbase shell> clone_snapshot 'tableSnapshot', 'newTableName'
4.删除快照 hbase shell> delete_snapshot 'tableSnapshot'
5.删除原来表 hbase shell> drop 'tableName'
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值