一、在MySQL workbench下更新数据库时不做相应的修改可能会报错。相应修改如下:
1、点击如下图红笔标出的地方

2、点击下图红笔标出的地方

3、将下图红笔标出的地方的“勾号”去掉之后,即可正常修改数据库。

二、在mysql控制台上更新数据库报错时相应的措施是运行以下代码:
set sql_safe_updates=0;
1、在students表中加入下学生信息
学号 姓名 性别 年龄 系别
1227 王润之 女 18 文学
1228 苏小小 女 17 历史
1229 王朝云 女 20 建筑
insert into students values('1227','王润之','男',19,'文学')
('1228','苏小小','女',18,'文学')
('1229','王朝云','女',21,'建筑')
2、在students表中加入以下学生信息
学号 姓名
1230 柳如是
insert into students(sno,sname) values('1230','柳如是')
3、拷贝students表到s表
create table s select * from students
4、 把所有同学的年龄增加一岁
update students
set sage=sage+1
5、将计算机系学生的成绩增加5分
update sc
set grade=grade+5
where sno in(select sno
from students
where sdept='计算机')
6、 删除文学系的女生信息
delete from students
where sdept='文学'
7、在s表中,把没有选课的学生信息删掉
delete from students
where sno not in(select sno
from sc)
7.1、删除s表中成绩为空的学生的信息
delete from students
where sno in(select sno
from sc
where grade is null)
3万+

被折叠的 条评论
为什么被折叠?



