您现在的位置是:首页 >技术教程 >hbase shell命令网站首页技术教程
hbase shell命令
                简介hbase shell命令            
            1. hbase 基本命令
-  
hbase shell # 进入hbase
 -  
help # 进入hbase后台,查看帮助信息
 -  
status # 查看hbase集群状态
 -  
version # 查看数据库版本
 -  
list # 查看数据库中所有的表
 -  
describe 'tablename' # 查看表的详细信息
 
2. 其他命令
2.1创建表StudentAndCourse,列簇为student、course1,course2、course3
create "StudentAndCourse", "student", "course1", "course2", "course3"  运行结果: hbase:002:0> create "StudentAndCourse", "student", "course1", "course2", "course3" Created table StudentAndCourse Took 1.1680 seconds => Hbase::Table - StudentAndCourse
查看表:
hbase:004:0> describe "StudentAndCourse"
Table StudentAndCourse is ENABLED
StudentAndCourse, {TABLE_ATTRIBUTES => {METADATA => {'hbase.store.file-tracker.impl' => 'DEFAULT'}}}
COLUMN FAMILIES DESCRIPTION
{NAME => 'course1', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', COMPRESSION => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', BLOCKCACHE => 'true
', BLOCKSIZE => '65536 B (64KB)', REPLICATION_SCOPE => '0'}
{NAME => 'course2', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', COMPRESSION => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', BLOCKCACHE => 'true
', BLOCKSIZE => '65536 B (64KB)', REPLICATION_SCOPE => '0'}
{NAME => 'course3', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', COMPRESSION => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', BLOCKCACHE => 'true
', BLOCKSIZE => '65536 B (64KB)', REPLICATION_SCOPE => '0'} 
{NAME => 'student', BLOOMFILTER => 'ROW', IN_MEMORY => 'false', VERSIONS => '1', KEEP_DELETED_CELLS => 'FALSE', DATA_BLOCK_ENCODING => 'NONE', COMPRESSION => 'NONE', TTL => 'FOREVER', MIN_VERSIONS => '0', BLOCKCACHE => 'true
', BLOCKSIZE => '65536 B (64KB)', REPLICATION_SCOPE => '0'}
4 row(s)
Quota is disabled
Took 0.0958 seconds
说明:
Table StudentAndCourse is ENABLED # 表状态,表是激活的(可用的)
TABLE_ATTRIBUTES => {METADATA => {'hbase.store.file-tracker.impl' => 'DEFAULT'}} # 使用默认的命名空间default,注意是小写,因为hbase默认有两个命名空间,一个是内置的hbase命名空间,存放hbase内置表,另一个是default命名空间,用户默认使用的命名空间。
COLUMN FAMILIES DESCRIPTION # 列簇描述,如上有四个列簇,course1、course2、course3、student(NAME => 列簇名) 
2.2 插入数据
新增学生信息 put 'StudentAndCourse' ,'2023003','student:S_Name','Lisi' put 'StudentAndCourse' ,'2023003','student:S_Sex','male' put 'StudentAndCourse' ,'2023003','student:S_Age','24' put 'StudentAndCourse' ,'2023003','course1:C_No','123001' put 'StudentAndCourse' ,'2023003','course1:C_Name','Math' put 'StudentAndCourse' ,'2023003','course1:C_Credit','2.0' put 'StudentAndCourse' ,'2023003','course1:Score','98' put 'StudentAndCourse' ,'2023003','course2:C_No','123002' put 'StudentAndCourse' ,'2023003','course2:C_Name','Computer Science' put 'StudentAndCourse' ,'2023003','course2:C_Credit','5.0' put 'StudentAndCourse' ,'2023003','course2:Score','95' ... ...
2.3 浏览数据
scan  2023003 column=course2:C_No, timestamp=2023-06-06T11:31:37.375, value=123002 2023003 column=course2:Score, timestamp=2023-06-06T11:31:38.057, value=95 2023003 column=student:S_Age, timestamp=2023-06-06T11:31:37.310, value=24 2023003 column=student:S_Name, timestamp=2023-06-06T11:31:37.279, value=Lisi 2023003 column=student:S_Sex, timestamp=2023-06-06T11:31:37.298, value=male
2.4 查看有哪些表
list  hbase:051:0> list TABLE  StudentAndCourse 1 row(s) Took 0.0167 seconds => ["StudentAndCourse"]  说明:默认为default命名空间
2.5 查看命名空间列表
list_namespace  hbase:049:0> list_namespace NAMESPACE default hbase 2 row(s)  第一个不是命名空间名称,是列名称-命名空间
2.6 查看命名空间下有哪些表
list_namespace_tables 'default' TABLE StudentAndCourse 1 row(s)
2.7 创建命名空间
create_namespace 'commerce'
-  
删除命名空间
 
drop_namespace 'commerce'
-  
使用创建的命名空间创建表
 
create 'commerce.province_city_info', 'provinceInfo', 'cityInfo'
2.8 删除表
删除表之前先停止表, 第一步: disable 'commerce.province_city_info' 第二步: drop 'commerce.province_city_info'
2.9 判断表是否存在
exists 'commerce.province_city_info'
2.10 新增列簇
alter 'commerce.province_city_info','otherInfo'
2.11 删除列簇
alter 'commerce.province_city_info','otherInfo',{NAME=>'otherInfo',METHOD=>'delete'} 
2.12 设置列簇记录三个版本
alter 'commerce.province_city_info',{NAME=>'provinceInfo',VERSIONS=>3} 
2.13 设置浏览列簇/cell
scan 'StudentAndCourse',{COLUMN=>'student'}
scan 'StudentAndCourse',{COLUMN=>'student:S_Name'} 
2.14 删除指定列簇下的列
delete 'StudentAndCourse','2023003','student:S_Age'
2.15 删除指定的rowkey
deleteall 'StudentAndCourse', '2015001'
风语者!平时喜欢研究各种技术,目前在从事后端开发工作,热爱生活、热爱工作。
        
    
        
    
            




U8W/U8W-Mini使用与常见问题解决
QT多线程的5种用法,通过使用线程解决UI主界面的耗时操作代码,防止界面卡死。...
stm32使用HAL库配置串口中断收发数据(保姆级教程)
分享几个国内免费的ChatGPT镜像网址(亲测有效)
Allegro16.6差分等长设置及走线总结