uu快3神彩_uu快3app开户_彩神争8

Hbase shell 常用命令

时间:2020-01-08 17:31:10 出处:uu快3神彩_uu快3app开户_彩神争8

下面这人 人儿看看HBase Shell的这人 基本操作命令,我列出了2个常用的HBase Shell命令,如下:

名称

命令表达式

创建表

create '表名称', '列名称1','列名称2','列名称N'

换成记录 

put '表名称', '行名称', '列名称:', '值'

查看记录

get '表名称', '行名称'

查看表中的记录总数

count '表名称'

删除记录

delete '表名' ,'行名称' , '列名称'

删除一张表

没能屏蔽该表,也能对该表进行删除,第一步 disable '表名称' 第二步 drop '表名称'

查看所有记录

scan "表名称" 

查看某个表某个列中所有数据

scan "表名称" , ['列名称:']

更新记录

要是 重写一遍进行覆盖

一、一般操作

1.查询服务器情況

hbase(main):024:0>status

3 servers, 0 dead,1.0000 average load

3.删除一一三个小多 列族,alter,disable,enable

这人 人儿前一天建了一三个小列族,要是 发现member_id这人 列族是多余的,不可能 他要是 主键,全都 这人 人儿要将其删除。

hbase(main):003:0>alter 'member',{NAME=>'member_id',METHOD=>'delete'}

5.删除id为temp的值的‘info:age’字段

hbase(main):016:0>delete 'member','temp','info:age'

0 row(s) in 0.030seconds

hbase(main):018:0>get 'member','temp'

COLUMN CELL 

0 row(s) in 0.030seconds

hbase(main):030:0>get 'member','xiaofeng','info:age' 

COLUMN CELL 

info:age timestamp=1321591025110, value=\x00\x00\x00\x00\x00\x00\x00\x02 

1 row(s) in 0.0130seconds

hbase(main):005:0>get 'member','scutshuxue','info:age' 

COLUMN CELL 

info:age timestamp=1321586571843, value=99 

1 row(s) in 0.0130seconds



1.插入2个记录

put'member','scutshuxue','info:age','24'

put'member','scutshuxue','info:birthday','1987-06-17'

put'member','scutshuxue','info:company','alibaba'

put'member','scutshuxue','address:contry','china'

put'member','scutshuxue','address:province','zhejiang'

put'member','scutshuxue','address:city','hangzhou'

1.创建一一三个小多 表

hbase(main):011:0>create 'member','member_id','address','info' 

0 row(s) in 1.2210seconds



4.全表扫描:

hbase(main):013:0>scan 'member'

ROW COLUMN+CELL 

scutshuxue column=address:city, timestamp=1321586240244, value=hangzhou 

scutshuxue column=address:contry, timestamp=1321586239126, value=china 

scutshuxue column=address:province, timestamp=1321586239197, value=zhejiang 

scutshuxue column=info:age,timestamp=1321586571843, value=99 

scutshuxue column=info:birthday, timestamp=1321586239015, value=1987-06-17 

scutshuxue column=info:company, timestamp=1321586239071, value=alibaba 

temp column=info:age, timestamp=1321589309775, value=59 

xiaofeng column=address:city, timestamp=132158624830, value=jieyang 

xiaofeng column=address:contry, timestamp=1321586248316, value=china 

xiaofeng column=address:province, timestamp=1321586248355, value=guangdong 

xiaofeng column=address:town, timestamp=1321586249564, value=xianqiao 

xiaofeng column=info:birthday, timestamp=1321586248202, value=1987-4-17 

xiaofeng column=info:company, timestamp=1321586248277, value=alibaba 

xiaofeng column=info:favorite, timestamp=1321586248241, value=movie 

3 row(s) in 0.0570seconds

2.获得表的描述

hbase(main):012:0>list

TABLE 

member 

1 row(s) in 0.0130seconds

hbase(main):006:0>describe 'member'

DESCRIPTION ENABLED 

{NAME => 'member', FAMILIES => [{NAME=> 'address', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', true 

VERSIONS => '3', COMPRESSION => 'NONE',TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'fa 

lse', BLOCKCACHE => 'true'}, {NAME =>'info', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSI 

ONS => '3', COMPRESSION => 'NONE', TTL=> '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'false', 

BLOCKCACHE => 'true'}]} 

1 row(s) in 0.0230seconds

本文转自 张冲andy 博客园博客,原文链接:http://www.cnblogs.com/andy6/p/7661111.html   ,如需转载请自行联系原作者



6.删除整行

获取一一三个小多 id,一一三个小多 列族的所有数据

hbase(main):002:0>get 'member','scutshuxue','info'

COLUMN CELL 

info:age timestamp=1321586238965, value=24 

info:birthday timestamp=1321586239015, value=1987-06-17 

info:company timestamp=1321586239071, value=alibaba 

3 row(s) in 0.0210seconds

8.判断表否是 disable

hbase(main):032:0>is_disabled 'member'

false 

0 row(s) in 0.0110seconds

报错,删除列族的前一天需要先将表给disable掉。

hbase(main):004:0>disable 'member' 

0 row(s) in 2.0390seconds

hbase(main):005:0>alter'member',NAME=>'member_id',METHOD=>'delete'

0 row(s) in 0.0530seconds

hbase(main):006:0>describe 'member'

DESCRIPTION ENABLED 

{NAME => 'member', FAMILIES => [{NAME=> 'address', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0',false 

VERSIONS => '3', COMPRESSION => 'NONE',TTL => '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'fa 

lse', BLOCKCACHE => 'true'}, {NAME =>'info', BLOOMFILTER => 'NONE', REPLICATION_SCOPE => '0', VERSI 

ONS => '3', COMPRESSION => 'NONE', TTL=> '2147483647', BLOCKSIZE => '65536', IN_MEMORY => 'false', 

BLOCKCACHE => 'true'}]} 

1 row(s) in 0.0230seconds

该列族不可能 删除,这人 人儿继续将表enable

hbase(main):008:0> enable 'member' 

0 row(s) in 2.0420seconds

hbase(main):025:0>version

0.90.4, r130278,Sun Jul 24 15:53:29 PDT 2011

二、DDL操作

hbase(main):001:0>deleteall 'member','xiaofeng'

0 row(s) in 0.3990seconds

hbase(main):011:0>get 'member','scutshuxue',{COLUMN=>'info:age',TIMESTAMP=>1321586571843}

COLUMN CELL 

info:age timestamp=1321586571843, value=99 

1 row(s) in 0.0130seconds

8.给‘xiaofeng’这人 id增加'info:age'字段,并使用counter实现递增

hbase(main):057:0*incr 'member','xiaofeng','info:age' 

COUNTER VALUE = 1

2.获取四根数据

获取一一三个小多 id的所有数据

hbase(main):001:0>get 'member','scutshuxue'

COLUMN CELL 

address:city timestamp=1321586240244, value=hangzhou 

address:contry timestamp=1321586239126, value=china 

address:province timestamp=1321586239197, value=zhejiang 

info:age timestamp=1321586238965, value=24 

info:birthday timestamp=1321586239015, value=1987-06-17 

info:company timestamp=1321586239071, value=alibaba 

6 row(s) in 0.4720seconds

获取当前count的值

hbase(main):069:0>get_counter 'member','xiaofeng','info:age' 

COUNTER VALUE = 2

9.将整张表清空:

7.判断表否是 enable

hbase(main):034:0>is_enabled 'member'

true 

0 row(s) in 0.0110seconds

7.查询表包含2个行:

hbase(main):019:0>count 'member' 

2 row(s) in 0.0130seconds



put'member','xiaofeng','info:birthday','1987-4-17'

put'member','xiaofeng','info:favorite','movie' 

put'member','xiaofeng','info:company','alibaba'

put'member','xiaofeng','address:contry','china'

put'member','xiaofeng','address:province','guangdong'

put'member','xiaofeng','address:city','jieyang'

put'member','xiaofeng','address:town','xianqiao'



6.查询表否是 指在

hbase(main):021:0>exists 'member'

Table member doesexist 

0 row(s) in 0.1610seconds



6.更新四根记录

将scutshuxue的年龄改成99

hbase(main):004:0>put 'member','scutshuxue','info:age' ,'99'

0 row(s) in 0.0210seconds



3.通过timestamp来获取一一三个小多 版本的数据

hbase(main):010:0>get 'member','scutshuxue',{COLUMN=>'info:age',TIMESTAMP=>1321586238965}

COLUMN CELL 

info:age timestamp=1321586238965, value=24 

1 row(s) in 0.0140seconds

hbase(main):030:0>drop 'temp_table'

0 row(s) in 1.1070seconds



5.drop一一三个小多 表

hbase(main):029:0>disable 'temp_table'

0 row(s) in 2.0590seconds

2.查询hive版本

hbase(main):058:0>get 'member','xiaofeng','info:age' 

COLUMN CELL 

info:age timestamp=1321590997648, value=\x00\x00\x00\x00\x00\x00\x00\x01 

1 row(s) in 0.0140seconds

hbase(main):059:0>incr 'member','xiaofeng','info:age'

COUNTER VALUE = 2

三、DML操作

ERROR: Table memberis enabled. Disable it first before altering.

4.列出所有的表

hbase(main):028:0>list

TABLE 

member 

temp_table 

2 row(s) in 0.030seconds

获取一一三个小多 id,一一三个小多 列族中一一三个小多 列的所有数据

hbase(main):002:0>get 'member','scutshuxue','info:age' 

COLUMN CELL 

info:age timestamp=1321586238965, value=24 

1 row(s) in 0.0320seconds

热门

热门标签