数据库之视图操作 Posted on 2018-07-23 | In 数据库 , 文章页 , 语法与例题 | | 建立计算机系学生视图CS_S ; 代码: 123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111create view CS_Sasselect *from Swhere SDEPT = '计算机' 结果: ![](http://47.100.4.8/wp-content/uploads/2018/07/1-5.png)* 建立计算机系女生视图CS_S1 ;代码:create view CS_S1asselect *from Swhere SDEPT = '计算机' and SSEX = '女' 截图: ![](http://47.100.4.8/wp-content/uploads/2018/07/2-3.png)* 建立无先修课(Cpno为NULL)的课程视图NP_C;代码:create view NP_Casselect *from Cwhere CPNO is NULL 截图: ![](http://47.100.4.8/wp-content/uploads/2018/07/3-2.png)* 建立计算机系选修1号课程的学生视图CS_S2 ;代码:create view CS_S2asselect S.*from S,SCwhere S.SNO = SC.SNO and SC.CNO = '1' 截图: ![](http://47.100.4.8/wp-content/uploads/2018/07/4-1.png)* 建立计算机系选修数据库课程学生视图CS_S3 ;代码:create view CS_S#asselect S.*from S,SC,Cwhere S.SNO = SC.SNO and C.CNO = SC.CNO and C.CNAME = '数据库' and SDEPT = '计算机' 截图: ![](http://47.100.4.8/wp-content/uploads/2018/07/5-1.png)* 将计算机系女生的年龄增加1岁;代码:update CS_S1set SAGE = SAGE + 1 截图: ![](http://47.100.4.8/wp-content/uploads/2018/07/6-1.png)* 对CS_S3中学生专业修改为电子;代码:update CS_S3set SDEPT = '电子'where SNO = 'E0002' 截图: 该学生被移出该视图了就 ![](http://47.100.4.8/wp-content/uploads/2018/07/7.png)* 分别删除以上定义的各个视图。代码:drop view CS_Sdrop view CS_S1drop view CS_S2drop view CS_S3drop view NP_C 截图: Hobby lead creation, technology change world. Post author: StriveZs Post link: 1462.html Copyright Notice: All articles in this blog are licensed under CC BY-NC-SA 3.0 unless stating additionally.