[01].操作hbase数据库
进入
hbase shell工具hbase shell

status查看状态

help查看帮助Group name: ddlCommands: alter, alter_async, alter_status, create, describe, disable, disable_all, drop, drop_all, enable, enable_all, exists, get_table, is_disabled, is_enabled, list, show_filtersGroup name: dmlCommands: append, count, delete, deleteall, get, get_counter, incr, put, scan, truncate, truncate_preserve
[02].表操作
输入
list查看(用户空间)当前拥有 的表
01.创建表
格式1:create ‘ NameSpace : TableName ‘ { NAME=>’liezuName’,VERSONS=>5 }
- NameSpace :命名空间(相当于数据库)
- TableName :表名
- NAME=>’liezuName’:列族的名称
VERSONS=>5:列族中每个单元格的(保留)版本,出现新版本的数据时,自动删除最旧版本
格式2:create ‘ TableName ‘ { NAME=>’f1’ } , { NAME=>’f2’ } , { NAME=>’f2’ }
使用默认的命名空间创建表
- 拥有三个列族:f1,f2,f3
简写:
create 'tableName','f1','f2','f3'开始实验
添加自定义的命名空间
hadoopcreate_namespace 'hadoop'

查看当前命名空间
list_namespace

执行建表命令
create 'hadoop:student','stu_info','sel_course'

用
list查看(用户空间)表
02.删除表
创建默认空间的表
create 'student','stu_info','sel_course'
由于我们没有指定命名空间,所以创建完成后会出现在默认空间中。

此时我们可以看到student和hadoop:student,我们删除默认空间的那个表。将表
disable(禁用)disable `student`
删除
drop 'student'
[03].数据操作
01.增加一个单元格数据
使用
put增加一个学生(名字:’Tom’,学号:’1001’)put 'hadoop:student' , '1001' , 'stu_info:name' , 'Tom'
02.put(也可以更改数据)
按学号(rowkey)查询
get 'hadoop:student' ,'1001'

插入
stature列(身高)180put 'hadoop:student' , '1001' , 'stu_info:stature', '180'
再次查询
03.scan
查询整张表的数据
scan 'hadoop:student'

继续创建学生
Lilyput 'hadoop:student' , '1002' , 'stu_info:name', 'Lily'

查看一下
scan 'hadoop:student'
04.scan一整行数据
添加
Tom的英语成绩put 'hadoop:student' , '1001' , 'sel_course:en', '85'
添加
Lily的数学成绩put 'hadoop:student' , '1002' , 'sel_course:ma', '90'
列出列族
sel_course下所有单元格数据scan 'hadoop:student' , {COLUMNS=>['sel_course']}

列出列族
sel_course下所有学生英语成绩scan 'hadoop:student' , {COLUMNS=>['sel_course:en']}

添加
Lily的身高put 'hadoop:student' , '1002' , 'stu_info:stature', '165'

列出列族
stu_info下所有学生身高scan 'hadoop:student' , {COLUMNS=>['stu_info:stature']}
05.delete
添加一个测试数据
put 'hadoop:student' , '1003' , 'stu_info:name', 'Bruth'

scan全表

- 删除此数据
delete 'hadoop:student' , '1003' , 'stu_info:name'

可以看出1003的数据已经没有了。
