大数据之Hadoop学习(八)HBase Shell数据库表创建


根据以下关系型数据库表,使用HBase Shell设计并创建适宜的HBase数据表
在这里插入图片描述

一、启动Hadoop和HBase

1.启动Hadoop
cd /usr/local/hadoop/
./sbin/start-dfs.sh

在这里插入图片描述

2.启动HBase
cd /usr/local/hbase/
bin/start-hbase.sh

在这里插入图片描述

3.进入shell
./bin/hbase shell

在这里插入图片描述

二、创建表

create 'StudentAdmin','student','course1','course2','course3'

在这里插入图片描述

三、插入数据

学号作为RowKey即行键,因此插入数据时不必在插入学生编号,同时课程建了三个列族,用于存储同一行键下的不同课程

①新增学号为2015001的学生的所有信息
put 'StudentAdmin','2015001','student:S_Name','Zhangsan'
put 'StudentAdmin','2015001','student:S_Age','23'
put 'StudentAdmin','2015001','student:S_Sex','male'
put 'StudentAdmin','2015001','course1:C_No','123001'
put 'StudentAdmin','2015001','course1:C_Name','Math'
put 'StudentAdmin','2015001','course1:C_Credit','2.0'
put 'StudentAdmin','2015001','course1:Score','86'
put 'StudentAdmin','2015001','course3:C_No','123003'
put 'StudentAdmin','2015001','course3:C_Name','English'
put 'StudentAdmin','2015001','course3:C_Credit','3.0'
put 'StudentAdmin','2015001','course3:Score','69'
②、新增学号为2015002的学生的所有信息
put 'StudentAdmin','2015002','student:S_Name','Mary'
put 'StudentAdmin','2015002','student:S_Age','22'
put 'StudentAdmin','2015002','student:S_Sex','female'
put 'StudentAdmin','2015002','course2:C_No','123002'
put 'StudentAdmin','2015002','course2:C_Name','Computer Science'
put 'StudentAdmin','2015002','course2:C_Credit','5.0'
put 'StudentAdmin','2015002','course2:Score','77'
put 'StudentAdmin','2015002','course3:C_No','123003'
put 'StudentAdmin','2015002','course3:C_Name','English'
put 'StudentAdmin','2015002','course3:C_Credit','3.0'
put 'StudentAdmin','2015002','course3:Score','99'
③、新增学号为2015003的学生的所有信息
put 'StudentAdmin','2015003','student:S_Name','Lisi'
put 'StudentAdmin','2015003','student:S_Age','24'
put 'StudentAdmin','2015003','student:S_Sex','male'
put 'StudentAdmin','2015003','course1:C_No','123001'
put 'StudentAdmin','2015003','course1:C_Name','Math'
put 'StudentAdmin','2015003','course1:C_Credit','2.0'
put 'StudentAdmin','2015003','course1:Score','98'
put 'StudentAdmin','2015003','course2:C_No','123002'
put 'StudentAdmin','2015003','course2:C_Name','Computer Science'
put 'StudentAdmin','2015003','course2:C_Credit','5.0'
put 'StudentAdmin','2015003','course2:Score','95'

四、查看表的数据

①、新增学号2015001的学生信息过后表的数据
get 'StudentAdmin','2015001'

在这里插入图片描述

②、新增学号为2015002的学生信息过后表的数据
get 'StudentAdmin','2015002'

在这里插入图片描述

③、学生信息全都新增过后表的数据
get 'StudentAdmin','2015003'

在这里插入图片描述

  • 3
    点赞
  • 52
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值