1.列出HBase所有的表的相关信息,例如表名;
list
2.在终端打印出指定的表的所有记录数据;
scan ‘student’
3.向已经创建好的表添加和删除指定的列族或列;
put ‘student’,’2018’,’Sname’,’boss’
delete ‘student’,’2018’,’Sname’
4.清空指定的表的所有记录数据;
truncate ‘student’
5.统计表的行数。
count ‘student’
(二)HBase数据库操作
1. 现有以下关系型数据库中的表和数据,要求将其转换为适合于HBase存储的表并插入数据:
学生表(Student)
学号(S_No) |
姓名(S_Name) |
性别(S_Sex) |
年龄(S_Age) |
2015001 |
Zhangsan |
male |
23 |
2015003 |
Mary |
female |
22 |
2015003 |
Lisi |
male |
24 |
创建Student表 如图1.1
Create ‘Student’,’S_No’,’S_Name’,’S_Sex’,’S_Age’
图1.1
添加属性如图1.2
put 'Student','s01','S_No','2015001'
put 'Student','s01','S_Name','Zhangsan'
put 'Student','s01','S_Sex','male'
put 'Student','s01','S_Age','23'
图1.2
添加属性如图1.3
put 'Student','s02','S_No','2015002'
put 'Student','s02','S_Name','Mary'
put 'Student','s02','S_Sex','female'
put 'Student','s02','S_Age','22'
图1.3
添加属性如图1.4
put 'Student','s03','S_No','2015003'
put 'Student','s03','S_Name','Lisi'
put 'Student','s03','S_Sex','male'
put 'Student','s03','S_Age','24'
图1.4
课程表(Course)
课程号(C_No) |
课程名(C_Name) |
学分(C_Credit) |
123001 |
Math |
2.0 |
123002 |
Computer Science |
5.0 |
123003 |
English |
3.0 |
创建Course表如图2.1
create 'Course','C_No','C_Name','C_Credit'
图2.1
put 'Course','c01','C_No','123001'
put 'Course','c01','C_Name','Math'
put 'Course','c01','C_Credit','2.0'
put 'Course','c02','C_No','123002'
put 'Course','c02','C_Name','Computer Science'
put 'Course','c02','C_Credit','5.0'
put 'Course','c03','C_No','123003'
put 'Course','c03','C_Name','English'
put 'Course','c03','C_Credit','3.0'
图2.2
选课表(SC)
学号(SC_Sno) |