实验9 数据更新
在Gradem或Gradem1数据库中完成下面操作:
注意:在完成实验题目前先备份Student、SC、Course这3个表,备份表名自定。
(1) 向Student表中插入记录(“20050203”,“张静”,“1981-3-21”,“女”,“CS”,“电子商务”)。
insert into student(sno,sname) values (“20050302”,“李四”);
(2) 插入学号为“20050302”、姓名为“李四”的学生信息。
create table ts like student;
insert into ts select * from student where sdept='计算机系';
(3) 将学号为“20050202”的学生姓名改为“张华”,系别改为“CS”,专业改为“多媒体技术”。
update student set sname='张华',sdept='CS',speciality='多媒体技术' where sno='20050202';
(4) 将“李勇”同学的专业改为“计算机信息管理”。
update student set sdept='计算机信息管理' where sname='李勇';
(5) 删除学号为“20050302”的学生记录。
delete from student where sno='20050302';
(6) 删除“计算机系”所有学生的选课记录。
delete from sc where '计算机系' = (select sdept from student a where a.sno=sc.sno);
(7) 删除SC表中尚无成绩的选课记录。
delete from sc where degree is null;
(8) 把“张晨”同学的成绩全部删除。
delete from sc where sc.sno in (select * from (select b.sno from student b where b.sname='张晨') c);
作者QQ:2535568540