#【例7.5】在stusys数据库中,以student为基表,创建专业为通信的可更新视图
alter view V_StudentScore
as
select a.sno as 学号,a.sname as 姓名,ssex as 性别,speciality as 专业,b.cno as 课程号,grade as 成绩
from student a,score b
where a.speciality='通信' and a.sno=b.sno;
#【例7.6】 向V_StudentSpecialityComm视图中插入一条记录:('196006','程超','男','1998-04-28','通信', 50)。
use stusys;
create view V_StudentSpecialityComm
as
select sno as 学号,sname as 姓名,ssex as 性别,sbirthday as 出生日期,speciality as 专业,tc as 学分
from student
where speciality='通信';
insert into V_StudentSpecialityComm
values('196006','程超','男','1998-04-28','通信',50);
select * from V_StudentSpecialityComm
#【例7.7】 将V_StudentSpecialityComm视图中学号为196006的学生的总学分增加2分。
use stusys;
update V_StudentSpecialityComm set 学分=学分+2
where 学号='196006';
select * from score;
select * from student;
#【例7.8】 删除V_StudentSpecialityComm视图中学号为196006的记录。
#【例7.9】 将例7.1定义的视图V_StudentScore视图进行修改,取消专业为计算机的要求。
#【例7.10】修改例7.2创建的视图V_StudentCourseScore,学号以降序排列。
#【例7.11】 在stusys数据库中,将视图V_StudentCourseScore删除。
use stusys;
drop view V_StudentCourseScore;
#【例7.12】 在stusys数据库中student表的sname列上,创建一个普通索引I_studentSname。
#【例7.13】 在stusys数据库中course表的cno列上,创建一个索引I_courseCno,要求按课程号cno字段值前2个字符降序排列。
#【例7.14】 在stusys数据库中student表的tc列(降序)和sname列(升序),创建一个组合索引I_studentTcSname。
#【例7.15】在stusys数据库teacher表的tname列,创建一个唯一性索引I_teacherTname,并按降序排列。
#【例7.16】在stusys数据库中,创建新表score1表,主键为sno和cno,同时在grade列上创建普通索引。
#【例7.17】查看例7.16所创建的score1表的索引。
show index from student;
#【例7.18】删除已建索引I_studentTcSname。
#【例7.19】删除已建索引I_teacherTname。
、