美文网首页
HBase Shell

HBase Shell

作者: 歌哥居士 | 来源:发表于2019-03-29 16:04 被阅读0次

list 列出Hbase的表

$ list
TABLE
student

=> ["student"]

create 创建表
student是表,info是列簇,必须要有一个起始列簇。

$ create 'student','info'

alter 变更表信息

$ alter 'student' , NAME => 'info' , VERSIONS => 3
Updating all regions with the new schema...
1/1 regions updated.
Done.

disable 禁用表

$ disable 'student'

drop 删除表
禁用表后删除

$ drop 'student'

describe 查看表信息

$ desc 'student' ($ describe 'student' 
Table student is ENABLED
student
COLUMN FAMILIES DESCRIPTION
{
NAME => 'info', 
BLOOMFILTER => 'ROW', 
VERSIONS => '1', 
IN_MEMORY => 'false', 
KEEP_DELETED_CELLS => 'FALSE', 
DATA_BLOCK_ENCODING => 'NONE', 
TTL => 'FOREVER', 
COMPRESSION => 'NONE', 
MIN_VERSIONS => '0', 
BLOCKCACHE => 'true', 
BLOCKSIZE => '65536', 
REPLICATION_SCOPE => '0'
}

count 计算有多少rowkey

$ count 'student'
=> 2

is_enabled 查看表是否启用

$ is_enabled 'student'
true

put 插入数据
put 表, 主键, 列簇:列, 值

$ put 'student','1001','info:name','baozi'
$ put 'student','1001','info:gender','male'
$ put 'student','1002','info:name','izoab'
$ put 'student','1002','info:gender','female'

delete 删除数据
delete 指定列
deleteall 指定主键

$ delete 'student','1001','info:name'
$ deleteall 'student','1002'

truncate 删除整表数据

$ truncate 'student'

scan 查询表数据
scan 表, {STARTROW ......}

$ scan 'student'
ROW                                  COLUMN+CELL
 1001                                column=info:gender, timestamp=1543888978736, value=male
 1001                                column=info:name, timestamp=1543888782514, value=baozi
 1002                                column=info:gender, timestamp=1543889006075, value=female
 1002                                column=info:name, timestamp=1543888996813, value=izoab

$ scan 'student',STARTROW => '1001'
ROW                                  COLUMN+CELL
 1001                                column=info:gender, timestamp=1543891686192, value=male
 1001                                column=info:name, timestamp=1543891673934, value=baozi
 1002                                column=info:gender, timestamp=1543891692338, value=female
 1002                                column=info:name, timestamp=1543891705030, value=izoab

$ scan 'student', STARTROW => '1001', STOPROW => '1002'
ROW                                  COLUMN+CELL
 1001                                column=info:gender, timestamp=1543891686192, value=male
 1001                                column=info:name, timestamp=1543891673934, value=baozi

get 查询数据
get 表 , 主键
get 表 , 主键 , 列簇
get 表 , 主键 , 列簇:列


$ get 'student','1001'
COLUMN                               CELL
 info:gender                         timestamp=1543888978736, value=male
 info:name                           timestamp=1543888782514, value=baozi

$ get 'student','1001','info'
COLUMN                               CELL
 info:gender                         timestamp=1543888978736, value=male
 info:name                           timestamp=1543888782514, value=baozi

$ get 'student','1001','info:name'
COLUMN                               CELL
 info:name                           timestamp=1543888782514, value=baozi

$ get 'student' , '1001' , COLUMN => 'info:name', VERSIONS => 3
COLUMN                               CELL
 info:name                           timestamp=1543891845779, value=baozi2
 info:name                           timestamp=1543891844237, value=baozi1
 info:name                           timestamp=1543891673934, value=baozi

$ get 'student' , '1001' , COLUMN => 'info:name', VERSIONS => 1
COLUMN                               CELL
 info:name                           timestamp=1543891845779, value=baozi2

命名空间操作

$ create_namespace 'bigdata'

$ list_namespace
NAMESPACE
bigdata
default
hbase

$ create 'bigdata:student','info'
=> Hbase::Table - bigdata:student

$ disable 'bigdata:student'

$ drop 'bigdata:student'

$ drop_namespace 'bigdata'

$ list_namespace
NAMESPACE
default
hbase

相关文章

网友评论

      本文标题:HBase Shell

      本文链接:https://www.haomeiwen.com/subject/sahxvqtx.html