数据库作业

作业1

create table student( id int primary key, name varchar(20) not null, grade float );

#在数据库中创建一个表student,用于存储学生信息

insert into student (id,name,grade) values('1','monkey','98.5');

#向student表中添加一条新记录 记录中id字段值1,name字段的值为"monkey",grade字段的值98.5

insert into student (id,name,grade) values('2','bob','95.5'),('3','john','90.0'),('4','smith','88.5');

#向student表中添加多条新记录 2,"bob",95.5 3,"john",90.0 4,"smith",88.5

insert into student (id,name) values('5','jone');

#向student表中添加一条新记录,部分数据插入 5,"jone"

update student

set grade = grade + 0.5

where grade > 90;

#更新表,grade 大于90的加0.5

delete from student

where grade is null;

#删除成绩为空的记录

作业2

create user test1@'localhost' identified by '123';

#创建一个用户test1使他只能本地登录拥有查询student表的权限

grant select on db_system.* to test1@'localhost' ;

#密码(没有用password)

show grants for test1@localhost;

#查询用户test1的权限

drop user test1@'localhost';

#删除用户test1

  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值